wad-lab 1.2.2 → 1.2.4

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.
Files changed (207) hide show
  1. package/bin/index.js +477 -627
  2. package/package.json +1 -1
  3. package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/App.vue +241 -429
  4. package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/components/ItemFormModal.vue +183 -0
  5. package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/components/ItemPatchModal.vue +193 -0
  6. package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/components/ItemTable.vue +177 -0
  7. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/App.vue +150 -441
  8. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/components/ItemFormModal.vue +207 -0
  9. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/components/ItemStats.vue +64 -0
  10. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/components/ItemTable.vue +195 -0
  11. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/App.vue +41 -90
  12. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/components/ItemFormModal.vue +173 -0
  13. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/components/ItemTable.vue +102 -0
  14. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/components/NavBar.vue +57 -0
  15. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/DepartmentView.vue +132 -296
  16. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/EmployeeView.vue +126 -219
  17. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/components/ItemDetail.vue +115 -0
  18. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/components/ItemTable.vue +104 -0
  19. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/components/SideBar.vue +59 -0
  20. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/CompanyLayout.vue +2 -51
  21. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/DepartmentListView.vue +92 -250
  22. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/EmployeeDetailView.vue +59 -181
  23. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/EmployeeListView.vue +67 -315
  24. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/App.vue +19 -70
  25. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/ItemFormModal.vue +173 -0
  26. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/ItemPatchModal.vue +144 -0
  27. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/ItemTable.vue +102 -0
  28. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/NavBar.vue +53 -0
  29. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/views/DepartmentView.vue +107 -229
  30. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/views/EmployeeView.vue +143 -257
  31. package/templates/game-bingo/script.js +1 -1
  32. package/templates/game-memory-cards/script.js +2 -2
  33. package/templates/game-rock-paper-scissors/index.html +3 -3
  34. package/templates/game-rock-paper-scissors/script.js +2 -2
  35. package/templates/game-tic-tac-toe/script.js +2 -2
  36. package/templates/game-whack-a-mole/index.html +9 -9
  37. package/templates/servlet-basic/WEB-INF/ItemServlet.java +13 -0
  38. package/templates/servlet-basic/WEB-INF/classes/ItemServlet.class +0 -0
  39. package/templates/servlet-flow/WEB-INF/HelloServlet.java +34 -25
  40. package/templates/servlet-flow/WEB-INF/classes/HelloServlet.class +0 -0
  41. package/templates/servlet-jdbc/WEB-INF/JdbcItemServlet.java +13 -0
  42. package/templates/servlet-jdbc/WEB-INF/classes/JdbcItemServlet.class +0 -0
  43. package/templates/snippets/mongo-queries-cheatsheet.txt +105 -0
  44. package/templates/springboot-2model-aggregation-join/.mvn/wrapper/maven-wrapper.properties +3 -0
  45. package/templates/springboot-2model-aggregation-join/mvnw +295 -0
  46. package/templates/springboot-2model-aggregation-join/mvnw.cmd +189 -0
  47. package/templates/springboot-2model-aggregation-join/pom.xml +54 -0
  48. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/AggregationApplication.java +11 -0
  49. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/controller/DepartmentController.java +65 -0
  50. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/controller/EmployeeController.java +65 -0
  51. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/dto/DepartmentStatsDTO.java +15 -0
  52. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/dto/EmployeeJoinDTO.java +19 -0
  53. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/model/Department.java +20 -0
  54. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/model/Employee.java +21 -0
  55. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/repository/DepartmentRepository.java +9 -0
  56. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/repository/EmployeeRepository.java +9 -0
  57. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/service/DepartmentService.java +81 -0
  58. package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/service/EmployeeService.java +80 -0
  59. package/templates/springboot-2model-aggregation-join/src/main/resources/application.properties +2 -0
  60. package/templates/springboot-2model-aggregation-join/src/test/java/com/example/aggregation/AggregationApplicationTests.java +13 -0
  61. package/templates/vue-2model-crud-patch/README.md +64 -0
  62. package/templates/vue-2model-crud-patch/index.html +12 -0
  63. package/templates/vue-2model-crud-patch/package-lock.json +1785 -0
  64. package/templates/vue-2model-crud-patch/package.json +21 -0
  65. package/templates/vue-2model-crud-patch/src/App.vue +63 -0
  66. package/templates/vue-2model-crud-patch/src/components/AnalyticsBoard.vue +291 -0
  67. package/templates/vue-2model-crud-patch/src/components/DepartmentFormModal.vue +138 -0
  68. package/templates/vue-2model-crud-patch/src/components/DepartmentPatchModal.vue +210 -0
  69. package/templates/vue-2model-crud-patch/src/components/DepartmentTable.vue +133 -0
  70. package/templates/vue-2model-crud-patch/src/components/EmployeeFormModal.vue +177 -0
  71. package/templates/vue-2model-crud-patch/src/components/EmployeePatchModal.vue +221 -0
  72. package/templates/vue-2model-crud-patch/src/components/EmployeeTable.vue +171 -0
  73. package/templates/vue-2model-crud-patch/src/components/NavBar.vue +156 -0
  74. package/templates/vue-2model-crud-patch/src/main.js +12 -0
  75. package/templates/vue-2model-crud-patch/src/router/index.js +33 -0
  76. package/templates/vue-2model-crud-patch/src/services/api.js +64 -0
  77. package/templates/vue-2model-crud-patch/src/stores/departmentStore.js +149 -0
  78. package/templates/vue-2model-crud-patch/src/stores/employeeStore.js +143 -0
  79. package/templates/vue-2model-crud-patch/src/style.css +415 -0
  80. package/templates/vue-2model-crud-patch/src/views/AnalyticsView.vue +59 -0
  81. package/templates/vue-2model-crud-patch/src/views/DepartmentsView.vue +135 -0
  82. package/templates/vue-2model-crud-patch/src/views/EmployeesView.vue +143 -0
  83. package/templates/vue-2model-crud-patch/vite.config.js +9 -0
  84. package/templates/vue-axios/src/App.vue +255 -264
  85. package/templates/vue-axios/src/components/ItemFormModal.vue +183 -0
  86. package/templates/vue-axios/src/components/ItemPatchModal.vue +193 -0
  87. package/templates/vue-axios/src/components/ItemTable.vue +177 -0
  88. package/templates/vue-axios-basic/src/App.vue +241 -429
  89. package/templates/vue-axios-basic/src/components/ItemFormModal.vue +183 -0
  90. package/templates/vue-axios-basic/src/components/ItemPatchModal.vue +193 -0
  91. package/templates/vue-axios-basic/src/components/ItemTable.vue +177 -0
  92. package/templates/vue-axios-pinia/src/App.vue +150 -441
  93. package/templates/vue-axios-pinia/src/components/ItemFormModal.vue +207 -0
  94. package/templates/vue-axios-pinia/src/components/ItemStats.vue +64 -0
  95. package/templates/vue-axios-pinia/src/components/ItemTable.vue +195 -0
  96. package/templates/vue-axios-router/src/App.vue +41 -90
  97. package/templates/vue-axios-router/src/components/ItemFormModal.vue +173 -0
  98. package/templates/vue-axios-router/src/components/ItemTable.vue +102 -0
  99. package/templates/vue-axios-router/src/components/NavBar.vue +57 -0
  100. package/templates/vue-axios-router/src/views/DepartmentView.vue +132 -296
  101. package/templates/vue-axios-router/src/views/EmployeeView.vue +126 -219
  102. package/templates/vue-axios-router-children/src/components/ItemDetail.vue +115 -0
  103. package/templates/vue-axios-router-children/src/components/ItemTable.vue +104 -0
  104. package/templates/vue-axios-router-children/src/components/SideBar.vue +59 -0
  105. package/templates/vue-axios-router-children/src/views/CompanyLayout.vue +2 -51
  106. package/templates/vue-axios-router-children/src/views/DepartmentListView.vue +92 -250
  107. package/templates/vue-axios-router-children/src/views/EmployeeDetailView.vue +59 -181
  108. package/templates/vue-axios-router-children/src/views/EmployeeListView.vue +67 -315
  109. package/templates/vue-axios-router-pinia/src/App.vue +19 -70
  110. package/templates/vue-axios-router-pinia/src/components/ItemFormModal.vue +173 -0
  111. package/templates/vue-axios-router-pinia/src/components/ItemPatchModal.vue +144 -0
  112. package/templates/vue-axios-router-pinia/src/components/ItemTable.vue +102 -0
  113. package/templates/vue-axios-router-pinia/src/components/NavBar.vue +53 -0
  114. package/templates/vue-axios-router-pinia/src/views/DepartmentView.vue +107 -229
  115. package/templates/vue-axios-router-pinia/src/views/EmployeeView.vue +143 -257
  116. package/templates/vue-banking-app/src/components/AccountOverview.vue +75 -0
  117. package/templates/vue-banking-app/src/components/TransactionForm.vue +89 -0
  118. package/templates/vue-banking-app/src/components/TransactionTable.vue +113 -0
  119. package/templates/vue-banking-app/src/stores/bankStore.js +16 -3
  120. package/templates/vue-banking-app/src/views/DashboardView.vue +23 -71
  121. package/templates/vue-banking-app/src/views/StatementView.vue +11 -158
  122. package/templates/vue-banking-app/src/views/TransactionFormView.vue +23 -121
  123. package/templates/vue-basics/src/App.vue +105 -76
  124. package/templates/vue-basics/src/components/CounterCard.vue +107 -0
  125. package/templates/vue-basics/src/components/ItemList.vue +99 -0
  126. package/templates/vue-basics/src/components/UserForm.vue +138 -0
  127. package/templates/vue-cart-router-pinia/src/components/CartSummary.vue +139 -0
  128. package/templates/vue-cart-router-pinia/src/components/CheckoutModal.vue +149 -0
  129. package/templates/vue-cart-router-pinia/src/components/ProductCard.vue +63 -0
  130. package/templates/vue-cart-router-pinia/src/stores/cartStore.js +11 -0
  131. package/templates/vue-cart-router-pinia/src/views/CartView.vue +52 -118
  132. package/templates/vue-cart-router-pinia/src/views/CheckoutView.vue +2 -5
  133. package/templates/vue-cart-router-pinia/src/views/ProductCatalogView.vue +20 -56
  134. package/templates/vue-employee-system/src/App.vue +75 -344
  135. package/templates/vue-employee-system/src/components/DepartmentFilter.vue +108 -0
  136. package/templates/vue-employee-system/src/components/EmployeeModal.vue +183 -0
  137. package/templates/vue-employee-system/src/components/EmployeeTable.vue +91 -0
  138. package/templates/vue-employee-system/src/stores/employeeStore.js +12 -0
  139. package/templates/vue-fetch/src/App.vue +261 -285
  140. package/templates/vue-fetch/src/components/FetchFormModal.vue +183 -0
  141. package/templates/vue-fetch/src/components/FetchPatchModal.vue +193 -0
  142. package/templates/vue-fetch/src/components/FetchTable.vue +177 -0
  143. package/templates/vue-food-ordering/src/components/CartSummary.vue +134 -0
  144. package/templates/vue-food-ordering/src/components/FoodMenu.vue +126 -0
  145. package/templates/vue-food-ordering/src/components/OrderModal.vue +150 -0
  146. package/templates/vue-food-ordering/src/views/MenuView.vue +11 -132
  147. package/templates/vue-food-ordering/src/views/OrderCartView.vue +31 -164
  148. package/templates/vue-game-rps/src/App.vue +29 -88
  149. package/templates/vue-game-tictactoe/src/App.vue +23 -53
  150. package/templates/vue-game-whackamole/src/App.vue +44 -63
  151. package/templates/vue-hospital-portal/src/components/AppointmentForm.vue +144 -0
  152. package/templates/vue-hospital-portal/src/components/DoctorCard.vue +73 -0
  153. package/templates/vue-hospital-portal/src/components/PatientTable.vue +123 -0
  154. package/templates/vue-hospital-portal/src/stores/hospitalStore.js +10 -1
  155. package/templates/vue-hospital-portal/src/views/OPDRegistrationView.vue +40 -416
  156. package/templates/vue-hospital-portal/src/views/PatientListView.vue +11 -301
  157. package/templates/vue-library-system/src/components/BookForm.vue +125 -0
  158. package/templates/vue-library-system/src/components/BookTable.vue +112 -0
  159. package/templates/vue-library-system/src/components/BorrowModal.vue +131 -0
  160. package/templates/vue-library-system/src/stores/libraryStore.js +26 -1
  161. package/templates/vue-library-system/src/views/BookCatalogView.vue +34 -415
  162. package/templates/vue-memory-game/src/App.vue +36 -40
  163. package/templates/vue-memory-game/src/stores/memoryStore.js +32 -37
  164. package/templates/vue-router/src/App.vue +24 -14
  165. package/templates/vue-router/src/components/AboutCard.vue +38 -0
  166. package/templates/vue-router/src/components/HomeHero.vue +75 -0
  167. package/templates/vue-router/src/components/NavBar.vue +54 -0
  168. package/templates/vue-router/src/views/ItemsLayout.vue +17 -9
  169. package/templates/vue-router/src/views/ListView.vue +106 -18
  170. package/templates/vue-router-pinia/src/App.vue +24 -14
  171. package/templates/vue-router-pinia/src/components/ItemFormModal.vue +163 -0
  172. package/templates/vue-router-pinia/src/components/ItemTable.vue +90 -0
  173. package/templates/vue-router-pinia/src/components/NavBar.vue +54 -0
  174. package/templates/vue-router-pinia/src/stores/itemStore.js +8 -1
  175. package/templates/vue-router-pinia/src/views/ListView.vue +78 -14
  176. package/templates/vue-router-pinia-springboot/frontend/src/App.vue +25 -8
  177. package/templates/vue-router-pinia-springboot/frontend/src/components/ItemFormModal.vue +183 -0
  178. package/templates/vue-router-pinia-springboot/frontend/src/components/ItemPatchModal.vue +193 -0
  179. package/templates/vue-router-pinia-springboot/frontend/src/components/ItemTable.vue +177 -0
  180. package/templates/vue-router-pinia-springboot/frontend/src/components/NavBar.vue +54 -0
  181. package/templates/vue-router-pinia-springboot/frontend/src/views/ListView.vue +92 -76
  182. package/templates/vue-springboot-mongo-aggregation/frontend/src/App.vue +184 -193
  183. package/templates/vue-springboot-mongo-aggregation/frontend/src/components/AnalyticsCards.vue +56 -0
  184. package/templates/vue-springboot-mongo-aggregation/frontend/src/components/CategorySummaryTable.vue +71 -0
  185. package/templates/vue-springboot-mongo-aggregation/frontend/src/components/ItemTable.vue +114 -0
  186. package/templates/vue-springboot-mongo-crud/frontend/src/App.vue +228 -158
  187. package/templates/vue-springboot-mongo-crud/frontend/src/components/ItemFormModal.vue +183 -0
  188. package/templates/vue-springboot-mongo-crud/frontend/src/components/ItemPatchModal.vue +193 -0
  189. package/templates/vue-springboot-mongo-crud/frontend/src/components/ItemTable.vue +177 -0
  190. package/templates/vue-symposium-system/src/App.vue +41 -256
  191. package/templates/vue-symposium-system/src/components/AttendeeTable.vue +100 -0
  192. package/templates/vue-symposium-system/src/components/EventCard.vue +67 -0
  193. package/templates/vue-symposium-system/src/components/RegistrationForm.vue +118 -0
  194. package/templates/vue-symposium-system/src/stores/symposiumStore.js +10 -0
  195. package/templates/vue-todo-pinia/src/App.vue +40 -138
  196. package/templates/vue-todo-pinia/src/components/TodoFilter.vue +74 -0
  197. package/templates/vue-todo-pinia/src/components/TodoInput.vue +53 -0
  198. package/templates/vue-todo-pinia/src/components/TodoList.vue +101 -0
  199. package/templates/vue-todo-pinia/src/stores/todoStore.js +6 -0
  200. package/templates/vue-todo-router/src/App.vue +5 -36
  201. package/templates/vue-todo-router/src/components/TodoForm.vue +78 -0
  202. package/templates/vue-todo-router/src/components/TodoList.vue +84 -0
  203. package/templates/vue-todo-router/src/components/TodoNavBar.vue +47 -0
  204. package/templates/vue-todo-router/src/data/todoState.js +7 -0
  205. package/templates/vue-todo-router/src/views/AddTodoView.vue +7 -66
  206. package/templates/vue-todo-router/src/views/TodoDetailView.vue +15 -1
  207. package/templates/vue-todo-router/src/views/TodoListView.vue +22 -64
@@ -1,91 +1,120 @@
1
1
  <script setup>
2
- import { ref, reactive, computed } from 'vue'
2
+ import { ref, computed } from 'vue'
3
+ import CounterCard from './components/CounterCard.vue'
4
+ import UserForm from './components/UserForm.vue'
5
+ import ItemList from './components/ItemList.vue'
3
6
 
4
7
  const items = ref([
5
8
  { id: '1', name: 'Notebook', description: 'Spiral ruled notebook', price: 15 },
6
9
  { id: '2', name: 'Pen', description: 'Blue gel pen', price: 5 }
7
10
  ])
8
11
 
9
- const form = reactive({
10
- name: '',
11
- description: '',
12
- price: 0
13
- })
14
-
15
- const itemCount = computed(() => {
16
- return items.value.length
17
- })
18
-
19
- const totalPrice = computed(() => {
20
- return items.value.reduce((sum, item) => sum + Number(item.price), 0)
21
- })
22
-
23
- function addItem() {
24
- if (!form.name) return
25
- items.value.push({
26
- id: String(Date.now()),
27
- name: form.name,
28
- description: form.description,
29
- price: Number(form.price)
30
- })
31
- form.name = ''
32
- form.description = ''
33
- form.price = 0
12
+ const isEditMode = ref(false)
13
+ const itemToEdit = ref(null)
14
+
15
+ const itemCount = computed(() => items.value.length)
16
+ const totalPrice = computed(() =>
17
+ items.value.reduce((sum, item) => sum + Number(item.price || 0), 0)
18
+ )
19
+
20
+ function handleAddOrUpdate(itemData) {
21
+ if (isEditMode.value) {
22
+ const idx = items.value.findIndex(i => i.id === itemData.id)
23
+ if (idx !== -1) {
24
+ items.value[idx] = { ...itemData }
25
+ }
26
+ isEditMode.value = false
27
+ itemToEdit.value = null
28
+ } else {
29
+ items.value.push({
30
+ id: String(Date.now()),
31
+ ...itemData
32
+ })
33
+ }
34
34
  }
35
35
 
36
- function deleteItem(id) {
36
+ function handleEdit(item) {
37
+ isEditMode.value = true
38
+ itemToEdit.value = { ...item }
39
+ }
40
+
41
+ function handlePatch(item) {
42
+ const newPrice = prompt('Enter new price for ' + item.name + ':', item.price)
43
+ if (newPrice !== null && newPrice !== '') {
44
+ const target = items.value.find(i => i.id === item.id)
45
+ if (target) {
46
+ target.price = Number(newPrice)
47
+ }
48
+ }
49
+ }
50
+
51
+ function handleDelete(id) {
37
52
  items.value = items.value.filter(item => item.id !== id)
38
53
  }
54
+
55
+ function handleCancelEdit() {
56
+ isEditMode.value = false
57
+ itemToEdit.value = null
58
+ }
39
59
  </script>
40
60
 
41
61
  <template>
42
- <h2>Vue Basics CRUD</h2>
43
- <br>
44
-
45
- <form @submit.prevent="addItem">
46
- <label for="name">Name:</label>
47
- <br>
48
- <input id="name" v-model="form.name" placeholder="Item Name" required>
49
- <br><br>
50
-
51
- <label for="description">Description:</label>
52
- <br>
53
- <input id="description" v-model="form.description" placeholder="Item Description" required>
54
- <br><br>
55
-
56
- <label for="price">Price:</label>
57
- <br>
58
- <input id="price" v-model.number="form.price" type="number" placeholder="Item Price" required>
59
- <br><br>
60
-
61
- <button type="submit">Add Item</button>
62
- </form>
63
-
64
- <br>
65
- <hr>
66
- <br>
67
-
68
- <h3>Item Statistics</h3>
69
- <br>
70
- <p>Total Items: {{ itemCount }}</p>
71
- <br>
72
- <p>Total Price: ${{ totalPrice }}</p>
73
-
74
- <br>
75
- <hr>
76
- <br>
77
-
78
- <h3>Items List</h3>
79
- <br>
80
-
81
- <p v-if="items.length === 0">No items available.</p>
82
-
83
- <ul v-if="items.length > 0">
84
- <li v-for="item in items" :key="item.id">
85
- <span>{{ item.name }} - {{ item.description }} - ${{ item.price }}</span>
86
- <br><br>
87
- <button @click="deleteItem(item.id)">Delete</button>
88
- <br><br>
89
- </li>
90
- </ul>
62
+ <div class="basics-container">
63
+ <header class="header">
64
+ <h2>Vue Basics CRUD</h2>
65
+ <p>Modular: CounterCard, UserForm, ItemList</p>
66
+ </header>
67
+
68
+ <CounterCard :total-items="itemCount" :total-price="totalPrice" />
69
+
70
+ <UserForm
71
+ :is-edit="isEditMode"
72
+ :item-to-edit="itemToEdit"
73
+ @submit-item="handleAddOrUpdate"
74
+ @cancel-edit="handleCancelEdit"
75
+ />
76
+
77
+ <ItemList
78
+ :items="items"
79
+ @edit-item="handleEdit"
80
+ @patch-item="handlePatch"
81
+ @delete-item="handleDelete"
82
+ />
83
+ </div>
91
84
  </template>
85
+
86
+ <style>
87
+ * {
88
+ box-sizing: border-box;
89
+ }
90
+
91
+ body {
92
+ margin: 0;
93
+ padding: 0;
94
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
95
+ background-color: #f8fafc;
96
+ color: #334155;
97
+ }
98
+ </style>
99
+
100
+ <style scoped>
101
+ .basics-container {
102
+ max-width: 800px;
103
+ margin: 30px auto;
104
+ padding: 0 16px;
105
+ }
106
+
107
+ .header {
108
+ margin-bottom: 20px;
109
+ }
110
+
111
+ .header h2 {
112
+ font-size: 24px;
113
+ margin-bottom: 4px;
114
+ }
115
+
116
+ .header p {
117
+ color: #64748b;
118
+ font-size: 14px;
119
+ }
120
+ </style>
@@ -0,0 +1,107 @@
1
+ <script setup>
2
+ import { ref } from 'vue'
3
+
4
+ defineProps({
5
+ totalItems: {
6
+ type: Number,
7
+ default: 0
8
+ },
9
+ totalPrice: {
10
+ type: Number,
11
+ default: 0
12
+ }
13
+ })
14
+
15
+ const counter = ref(0)
16
+ </script>
17
+
18
+ <template>
19
+ <div class="stats-card">
20
+ <div class="stat-box">
21
+ <span class="label">Total Items</span>
22
+ <strong class="value">{{ totalItems }}</strong>
23
+ </div>
24
+ <div class="stat-box">
25
+ <span class="label">Total Price</span>
26
+ <strong class="value">${{ Number(totalPrice).toFixed(2) }}</strong>
27
+ </div>
28
+ <div class="counter-box">
29
+ <span class="label">Interactive Counter</span>
30
+ <div class="counter-controls">
31
+ <button type="button" class="btn btn-sm" @click="counter--">-</button>
32
+ <span class="counter-num">{{ counter }}</span>
33
+ <button type="button" class="btn btn-sm" @click="counter++">+</button>
34
+ <button type="button" class="btn btn-sm btn-reset" @click="counter = 0">Reset</button>
35
+ </div>
36
+ </div>
37
+ </div>
38
+ </template>
39
+
40
+ <style scoped>
41
+ .stats-card {
42
+ display: flex;
43
+ gap: 16px;
44
+ flex-wrap: wrap;
45
+ background: #ffffff;
46
+ border: 1px solid #d0d7de;
47
+ border-radius: 8px;
48
+ padding: 16px;
49
+ margin-bottom: 20px;
50
+ }
51
+
52
+ .stat-box {
53
+ flex: 1;
54
+ min-width: 140px;
55
+ display: flex;
56
+ flex-direction: column;
57
+ gap: 4px;
58
+ }
59
+
60
+ .counter-box {
61
+ flex: 1.5;
62
+ min-width: 200px;
63
+ display: flex;
64
+ flex-direction: column;
65
+ gap: 4px;
66
+ }
67
+
68
+ .label {
69
+ font-size: 12px;
70
+ color: #64748b;
71
+ text-transform: uppercase;
72
+ font-weight: 600;
73
+ }
74
+
75
+ .value {
76
+ font-size: 20px;
77
+ color: #0f172a;
78
+ }
79
+
80
+ .counter-controls {
81
+ display: flex;
82
+ align-items: center;
83
+ gap: 8px;
84
+ margin-top: 4px;
85
+ }
86
+
87
+ .counter-num {
88
+ font-weight: 700;
89
+ font-size: 16px;
90
+ min-width: 24px;
91
+ text-align: center;
92
+ }
93
+
94
+ .btn {
95
+ padding: 4px 10px;
96
+ border-radius: 4px;
97
+ border: 1px solid #cbd5e1;
98
+ background: #f1f5f9;
99
+ cursor: pointer;
100
+ font-weight: 600;
101
+ }
102
+
103
+ .btn-reset {
104
+ font-size: 11px;
105
+ font-weight: normal;
106
+ }
107
+ </style>
@@ -0,0 +1,99 @@
1
+ <script setup>
2
+ defineProps({
3
+ items: {
4
+ type: Array,
5
+ required: true
6
+ }
7
+ })
8
+
9
+ const emit = defineEmits(['edit-item', 'patch-item', 'delete-item'])
10
+ </script>
11
+
12
+ <template>
13
+ <div class="list-container">
14
+ <h3>Item List</h3>
15
+ <table class="items-table">
16
+ <thead>
17
+ <tr>
18
+ <th>Name</th>
19
+ <th>Description</th>
20
+ <th>Price</th>
21
+ <th>Actions</th>
22
+ </tr>
23
+ </thead>
24
+ <tbody>
25
+ <tr v-if="items.length === 0">
26
+ <td colspan="4" class="empty">No items available.</td>
27
+ </tr>
28
+ <tr v-for="item in items" :key="item.id">
29
+ <td class="font-bold">{{ item.name }}</td>
30
+ <td>{{ item.description }}</td>
31
+ <td>${{ Number(item.price).toFixed(2) }}</td>
32
+ <td class="actions-cell">
33
+ <button type="button" class="btn btn-sm btn-edit" @click="emit('edit-item', item)">Edit</button>
34
+ <button type="button" class="btn btn-sm btn-patch" @click="emit('patch-item', item)">Patch</button>
35
+ <button type="button" class="btn btn-sm btn-delete" @click="emit('delete-item', item.id)">Delete</button>
36
+ </td>
37
+ </tr>
38
+ </tbody>
39
+ </table>
40
+ </div>
41
+ </template>
42
+
43
+ <style scoped>
44
+ .list-container {
45
+ background: #ffffff;
46
+ border: 1px solid #d0d7de;
47
+ border-radius: 8px;
48
+ padding: 16px;
49
+ }
50
+
51
+ .list-container h3 {
52
+ font-size: 16px;
53
+ margin-bottom: 12px;
54
+ }
55
+
56
+ .items-table {
57
+ width: 100%;
58
+ border-collapse: collapse;
59
+ font-size: 14px;
60
+ }
61
+
62
+ th, td {
63
+ padding: 10px 12px;
64
+ border-bottom: 1px solid #e2e8f0;
65
+ text-align: left;
66
+ }
67
+
68
+ th {
69
+ background: #f8fafc;
70
+ color: #475569;
71
+ }
72
+
73
+ .font-bold {
74
+ font-weight: 600;
75
+ }
76
+
77
+ .actions-cell {
78
+ display: flex;
79
+ gap: 6px;
80
+ }
81
+
82
+ .empty {
83
+ text-align: center;
84
+ color: #94a3b8;
85
+ padding: 20px;
86
+ }
87
+
88
+ .btn {
89
+ padding: 4px 8px;
90
+ border-radius: 4px;
91
+ font-size: 12px;
92
+ cursor: pointer;
93
+ border: 1px solid transparent;
94
+ }
95
+
96
+ .btn-edit { background: #0284c7; color: #fff; }
97
+ .btn-patch { background: #8250df; color: #fff; }
98
+ .btn-delete { background: #cf222e; color: #fff; }
99
+ </style>
@@ -0,0 +1,138 @@
1
+ <script setup>
2
+ import { reactive, watch } from 'vue'
3
+
4
+ const props = defineProps({
5
+ isEdit: {
6
+ type: Boolean,
7
+ default: false
8
+ },
9
+ itemToEdit: {
10
+ type: Object,
11
+ default: null
12
+ }
13
+ })
14
+
15
+ const emit = defineEmits(['submit-item', 'cancel-edit'])
16
+
17
+ const form = reactive({
18
+ id: '',
19
+ name: '',
20
+ description: '',
21
+ price: 0
22
+ })
23
+
24
+ watch(
25
+ () => props.itemToEdit,
26
+ (val) => {
27
+ if (val) {
28
+ form.id = val.id
29
+ form.name = val.name
30
+ form.description = val.description
31
+ form.price = Number(val.price)
32
+ } else {
33
+ form.id = ''
34
+ form.name = ''
35
+ form.description = ''
36
+ form.price = 0
37
+ }
38
+ },
39
+ { immediate: true }
40
+ )
41
+
42
+ function handleSubmit() {
43
+ if (!form.name.trim()) return
44
+ emit('submit-item', { ...form, price: Number(form.price) })
45
+ if (!props.isEdit) {
46
+ form.name = ''
47
+ form.description = ''
48
+ form.price = 0
49
+ }
50
+ }
51
+ </script>
52
+
53
+ <template>
54
+ <div class="form-container">
55
+ <h3>{{ isEdit ? 'Edit Item' : 'Add New Item' }}</h3>
56
+ <form @submit.prevent="handleSubmit" class="item-form">
57
+ <div class="form-group">
58
+ <label for="basic-name">Name</label>
59
+ <input id="basic-name" v-model="form.name" required placeholder="Item Name" />
60
+ </div>
61
+
62
+ <div class="form-group">
63
+ <label for="basic-desc">Description</label>
64
+ <input id="basic-desc" v-model="form.description" required placeholder="Item Description" />
65
+ </div>
66
+
67
+ <div class="form-group">
68
+ <label for="basic-price">Price ($)</label>
69
+ <input id="basic-price" v-model.number="form.price" type="number" step="any" min="0" required placeholder="0.00" />
70
+ </div>
71
+
72
+ <div class="form-actions">
73
+ <button type="submit" class="btn btn-primary">{{ isEdit ? 'Update Item' : 'Add Item' }}</button>
74
+ <button v-if="isEdit" type="button" class="btn btn-secondary" @click="emit('cancel-edit')">Cancel</button>
75
+ </div>
76
+ </form>
77
+ </div>
78
+ </template>
79
+
80
+ <style scoped>
81
+ .form-container {
82
+ background: #ffffff;
83
+ border: 1px solid #d0d7de;
84
+ border-radius: 8px;
85
+ padding: 16px;
86
+ margin-bottom: 20px;
87
+ }
88
+
89
+ .form-container h3 {
90
+ font-size: 16px;
91
+ margin-bottom: 12px;
92
+ }
93
+
94
+ .item-form {
95
+ display: flex;
96
+ gap: 12px;
97
+ flex-wrap: wrap;
98
+ align-items: flex-end;
99
+ }
100
+
101
+ .form-group {
102
+ display: flex;
103
+ flex-direction: column;
104
+ gap: 4px;
105
+ flex: 1;
106
+ min-width: 140px;
107
+ }
108
+
109
+ .form-group label {
110
+ font-size: 12px;
111
+ font-weight: 600;
112
+ color: #475569;
113
+ }
114
+
115
+ .form-group input {
116
+ padding: 8px 10px;
117
+ border: 1px solid #cbd5e1;
118
+ border-radius: 6px;
119
+ font-size: 14px;
120
+ }
121
+
122
+ .form-actions {
123
+ display: flex;
124
+ gap: 8px;
125
+ }
126
+
127
+ .btn {
128
+ padding: 8px 14px;
129
+ border-radius: 6px;
130
+ cursor: pointer;
131
+ border: 1px solid transparent;
132
+ font-size: 13px;
133
+ font-weight: 500;
134
+ }
135
+
136
+ .btn-primary { background: #0284c7; color: #fff; }
137
+ .btn-secondary { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
138
+ </style>
@@ -0,0 +1,139 @@
1
+ <script setup>
2
+ defineProps({
3
+ items: {
4
+ type: Array,
5
+ required: true
6
+ },
7
+ total: {
8
+ type: Number,
9
+ required: true
10
+ }
11
+ })
12
+
13
+ const emit = defineEmits(['increment', 'decrement', 'patch', 'remove', 'clear'])
14
+
15
+ function handlePatchQuantity(item) {
16
+ const newQty = prompt('Enter new quantity for ' + item.name + ':', item.quantity)
17
+ if (newQty !== null && newQty !== '') {
18
+ emit('patch', { id: item.id, quantity: Number(newQty) })
19
+ }
20
+ }
21
+ </script>
22
+
23
+ <template>
24
+ <div class="cart-summary">
25
+ <table class="cart-table">
26
+ <thead>
27
+ <tr>
28
+ <th>Product</th>
29
+ <th>Price</th>
30
+ <th>Qty</th>
31
+ <th>Subtotal</th>
32
+ <th>Actions</th>
33
+ </tr>
34
+ </thead>
35
+ <tbody>
36
+ <tr v-if="items.length === 0">
37
+ <td colspan="5" class="empty">Your cart is empty.</td>
38
+ </tr>
39
+ <tr v-for="item in items" :key="item.id">
40
+ <td>{{ item.name }}</td>
41
+ <td>${{ item.price }}</td>
42
+ <td>
43
+ <div class="qty-controls">
44
+ <button type="button" class="btn-qty" @click="emit('decrement', item.id)">-</button>
45
+ <span>{{ item.quantity }}</span>
46
+ <button type="button" class="btn-qty" @click="emit('increment', item.id)">+</button>
47
+ </div>
48
+ </td>
49
+ <td>${{ item.price * item.quantity }}</td>
50
+ <td class="action-cell">
51
+ <button type="button" class="btn btn-sm btn-patch" @click="handlePatchQuantity(item)">Patch</button>
52
+ <button type="button" class="btn btn-sm btn-danger" @click="emit('remove', item.id)">Remove</button>
53
+ </td>
54
+ </tr>
55
+ </tbody>
56
+ </table>
57
+
58
+ <div v-if="items.length > 0" class="summary-footer">
59
+ <button type="button" class="btn btn-secondary" @click="emit('clear')">Clear Cart</button>
60
+ <div class="total-display">
61
+ Total: <strong>${{ total }}</strong>
62
+ </div>
63
+ </div>
64
+ </div>
65
+ </template>
66
+
67
+ <style scoped>
68
+ .cart-summary {
69
+ background: #ffffff;
70
+ border: 1px solid #ddd;
71
+ border-radius: 8px;
72
+ padding: 16px;
73
+ }
74
+
75
+ .cart-table {
76
+ width: 100%;
77
+ border-collapse: collapse;
78
+ font-size: 14px;
79
+ }
80
+
81
+ th, td {
82
+ padding: 10px;
83
+ border-bottom: 1px solid #eee;
84
+ text-align: left;
85
+ }
86
+
87
+ th {
88
+ background: #f8fafc;
89
+ }
90
+
91
+ .qty-controls {
92
+ display: flex;
93
+ align-items: center;
94
+ gap: 6px;
95
+ }
96
+
97
+ .btn-qty {
98
+ width: 24px;
99
+ height: 24px;
100
+ border-radius: 4px;
101
+ border: 1px solid #ccc;
102
+ background: #f1f5f9;
103
+ cursor: pointer;
104
+ }
105
+
106
+ .action-cell {
107
+ display: flex;
108
+ gap: 6px;
109
+ }
110
+
111
+ .btn {
112
+ padding: 4px 8px;
113
+ border-radius: 4px;
114
+ cursor: pointer;
115
+ border: 1px solid transparent;
116
+ font-size: 12px;
117
+ }
118
+
119
+ .btn-patch { background: #8250df; color: #fff; }
120
+ .btn-danger { background: #cf222e; color: #fff; }
121
+ .btn-secondary { background: #f1f5f9; color: #475569; }
122
+
123
+ .summary-footer {
124
+ display: flex;
125
+ justify-content: space-between;
126
+ align-items: center;
127
+ margin-top: 16px;
128
+ }
129
+
130
+ .total-display {
131
+ font-size: 18px;
132
+ }
133
+
134
+ .empty {
135
+ text-align: center;
136
+ color: #888;
137
+ padding: 20px;
138
+ }
139
+ </style>