@stacksjs/defaults 0.75.529 → 0.75.537

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 (248) hide show
  1. package/ai/skills/stacks-actions/SKILL.md +1 -1
  2. package/ai/skills/stacks-build/SKILL.md +1 -1
  3. package/ai/skills/stacks-dashboard/SKILL.md +2 -2
  4. package/ai/skills/stacks-database/SKILL.md +1 -1
  5. package/ai/skills/stacks-migrations/SKILL.md +2 -2
  6. package/ai/skills/stacks-native/CATALOG.md +6 -6
  7. package/app/Actions/Dashboard/Commerce/CommerceCouponsAction.ts +27 -15
  8. package/app/Actions/Dashboard/Commerce/CommerceCouponsExportAction.ts +45 -0
  9. package/app/Actions/Dashboard/Commerce/CommerceCustomersAction.ts +22 -12
  10. package/app/Actions/Dashboard/Commerce/CommerceCustomersExportAction.ts +44 -0
  11. package/app/Actions/Dashboard/Commerce/CommercePosCheckoutAction.ts +9 -29
  12. package/app/Actions/Dashboard/Commerce/CommercePrintDevicesAction.ts +7 -9
  13. package/app/Actions/Dashboard/Commerce/CommerceProductDetailAction.ts +9 -8
  14. package/app/Actions/Dashboard/Commerce/CommerceTaxesAction.ts +7 -9
  15. package/app/Actions/Dashboard/Commerce/ManufacturerIndexAction.ts +8 -20
  16. package/app/Actions/Dashboard/Commerce/commerce-coupon-list.test.ts +203 -0
  17. package/app/Actions/Dashboard/Commerce/commerce-coupon-list.ts +248 -0
  18. package/app/Actions/Dashboard/Commerce/commerce-customer-list.test.ts +183 -0
  19. package/app/Actions/Dashboard/Commerce/commerce-customer-list.ts +186 -0
  20. package/app/Actions/Dashboard/Commerce/commerce-customer-records.test.ts +1 -34
  21. package/app/Actions/Dashboard/Commerce/commerce-customer-records.ts +0 -11
  22. package/app/Actions/Dashboard/Commerce/commerce-manufacturer-list.test.ts +118 -0
  23. package/app/Actions/Dashboard/Commerce/commerce-manufacturer-list.ts +41 -0
  24. package/app/Actions/Dashboard/Commerce/commerce-pos-catalog.test.ts +17 -5
  25. package/app/Actions/Dashboard/Commerce/commerce-pos-catalog.ts +17 -3
  26. package/app/Actions/Dashboard/Commerce/commerce-print-device-list.test.ts +99 -0
  27. package/app/Actions/Dashboard/Commerce/commerce-print-device-list.ts +18 -0
  28. package/app/Actions/Dashboard/Commerce/commerce-product-list.ts +5 -5
  29. package/app/Actions/Dashboard/Commerce/commerce-product-options.test.ts +81 -0
  30. package/app/Actions/Dashboard/Commerce/commerce-tax-rate-list.test.ts +99 -0
  31. package/app/Actions/Dashboard/Commerce/commerce-tax-rate-list.ts +18 -0
  32. package/app/Actions/Dashboard/Commerce/coupon-records.test.ts +1 -16
  33. package/app/Actions/Dashboard/Commerce/coupon-records.ts +6 -10
  34. package/app/Actions/Dashboard/Commerce/manufacturer-records.test.ts +5 -17
  35. package/app/Actions/Dashboard/Commerce/manufacturer-records.ts +0 -29
  36. package/app/Actions/Dashboard/Email/captured-mail.test.ts +16 -0
  37. package/app/Actions/Dashboard/Email/captured-mail.ts +9 -1
  38. package/app/Actions/Dashboard/Models/model-write.ts +36 -3
  39. package/app/Actions/Dashboard/Notifications/NotificationDeliveryHistoryAction.ts +13 -58
  40. package/app/Actions/Dashboard/Notifications/notification-delivery-history.ts +74 -0
  41. package/app/Actions/SitemapAction.ts +3 -1
  42. package/app/Models/Notification.ts +3 -1
  43. package/app/Models/NotificationDelivery.ts +4 -0
  44. package/app/Models/User.ts +10 -1
  45. package/bootstrap.ts +10 -2
  46. package/functions/commerce/tax-types.ts +21 -0
  47. package/functions/dashboard-list.test.ts +16 -0
  48. package/functions/dashboard-list.ts +14 -6
  49. package/functions/dashboard-model-record.test.ts +139 -0
  50. package/functions/dashboard-model-record.ts +353 -0
  51. package/functions/monitoring/errors.ts +22 -103
  52. package/functions/notifications/deliveries.ts +7 -38
  53. package/functions/queries.ts +7 -10
  54. package/ide/vscode/package.json +1 -1
  55. package/package.json +5 -5
  56. package/resources/components/Dashboard/Analytics/AnalyticsHub.stx +2 -2
  57. package/resources/components/Dashboard/Analytics/CampaignAnalytics.stx +22 -28
  58. package/resources/components/Dashboard/Analytics/EventAnalytics.stx +26 -34
  59. package/resources/components/Dashboard/Analytics/SalesAnalytics.stx +29 -37
  60. package/resources/components/Dashboard/Analytics/WebAnalyticsBreakdown.stx +12 -16
  61. package/resources/components/Dashboard/Analytics/WebAnalyticsDashboard.stx +43 -53
  62. package/resources/components/Dashboard/App/RequestsOverview.stx +2 -1
  63. package/resources/components/Dashboard/App/SourceInventory.stx +2 -1
  64. package/resources/components/Dashboard/Auth/AccessTokens.stx +3 -5
  65. package/resources/components/Dashboard/Billing/BillingPaymentMethodsPanel.stx +9 -11
  66. package/resources/components/Dashboard/Billing/BillingSettings.stx +1 -1
  67. package/resources/components/Dashboard/Buddy/BuddyAssistant.stx +4 -6
  68. package/resources/components/Dashboard/Commerce/CommerceCategoriesDashboard.stx +2 -2
  69. package/resources/components/Dashboard/Commerce/CommerceCategoriesTable.stx +3 -3
  70. package/resources/components/Dashboard/Commerce/CommerceCategoryDialog.stx +2 -2
  71. package/resources/components/Dashboard/Commerce/CommerceCategoryHierarchy.stx +3 -5
  72. package/resources/components/Dashboard/Commerce/CommerceCouponBreakdown.stx +17 -13
  73. package/resources/components/Dashboard/Commerce/CommerceCouponDialog.stx +1 -1
  74. package/resources/components/Dashboard/Commerce/CommerceCouponsDashboard.stx +57 -85
  75. package/resources/components/Dashboard/Commerce/CommerceCouponsTable.stx +32 -9
  76. package/resources/components/Dashboard/Commerce/CommerceCustomerDialog.stx +1 -1
  77. package/resources/components/Dashboard/Commerce/CommerceCustomersDashboard.stx +49 -83
  78. package/resources/components/Dashboard/Commerce/CommerceCustomersTable.stx +32 -9
  79. package/resources/components/Dashboard/Commerce/CommerceGiftCardBreakdown.stx +9 -15
  80. package/resources/components/Dashboard/Commerce/CommerceGiftCardDialog.stx +1 -1
  81. package/resources/components/Dashboard/Commerce/CommerceGiftCardsDashboard.stx +35 -119
  82. package/resources/components/Dashboard/Commerce/CommerceGiftCardsTable.stx +3 -3
  83. package/resources/components/Dashboard/Commerce/CommerceManufacturerDialog.stx +1 -1
  84. package/resources/components/Dashboard/Commerce/CommerceManufacturersDashboard.stx +3 -5
  85. package/resources/components/Dashboard/Commerce/CommerceManufacturersTable.stx +2 -2
  86. package/resources/components/Dashboard/Commerce/CommerceOrderDialog.stx +4 -4
  87. package/resources/components/Dashboard/Commerce/CommerceOrdersDashboard.stx +42 -129
  88. package/resources/components/Dashboard/Commerce/CommerceOrdersTable.stx +3 -3
  89. package/resources/components/Dashboard/Commerce/CommerceOverviewDashboard.stx +1 -1
  90. package/resources/components/Dashboard/Commerce/CommerceOverviewOrdersTable.stx +9 -11
  91. package/resources/components/Dashboard/Commerce/CommerceOverviewProductsTable.stx +5 -7
  92. package/resources/components/Dashboard/Commerce/CommerceOverviewStats.stx +14 -16
  93. package/resources/components/Dashboard/Commerce/CommercePaymentsBreakdown.stx +12 -18
  94. package/resources/components/Dashboard/Commerce/CommercePaymentsDashboard.stx +41 -120
  95. package/resources/components/Dashboard/Commerce/CommercePaymentsTable.stx +1 -1
  96. package/resources/components/Dashboard/Commerce/CommercePosCart.stx +13 -15
  97. package/resources/components/Dashboard/Commerce/CommercePosCatalog.stx +17 -19
  98. package/resources/components/Dashboard/Commerce/CommercePosCheckoutDialog.stx +2 -2
  99. package/resources/components/Dashboard/Commerce/CommercePosDashboard.stx +1 -1
  100. package/resources/components/Dashboard/Commerce/CommercePosReceiptDialog.stx +1 -1
  101. package/resources/components/Dashboard/Commerce/CommerceProductDetailDashboard.stx +5 -5
  102. package/resources/components/Dashboard/Commerce/CommerceProductDialog.stx +3 -3
  103. package/resources/components/Dashboard/Commerce/CommerceProductsDashboard.stx +41 -122
  104. package/resources/components/Dashboard/Commerce/CommerceProductsTable.stx +3 -3
  105. package/resources/components/Dashboard/Commerce/CommerceReviewEditDialog.stx +1 -1
  106. package/resources/components/Dashboard/Commerce/CommerceReviewsDashboard.stx +38 -122
  107. package/resources/components/Dashboard/Commerce/CommerceReviewsTable.stx +2 -2
  108. package/resources/components/Dashboard/Commerce/CommerceTaxDialog.stx +3 -3
  109. package/resources/components/Dashboard/Commerce/CommerceTaxesDashboard.stx +5 -4
  110. package/resources/components/Dashboard/Commerce/CommerceTaxesTable.stx +4 -3
  111. package/resources/components/Dashboard/Commerce/CommerceUnitDialog.stx +3 -7
  112. package/resources/components/Dashboard/Commerce/CommerceUnitsDashboard.stx +3 -5
  113. package/resources/components/Dashboard/Commerce/CommerceUnitsTable.stx +2 -2
  114. package/resources/components/Dashboard/Commerce/CommerceVariantDialog.stx +3 -3
  115. package/resources/components/Dashboard/Commerce/CommerceVariantsDashboard.stx +4 -4
  116. package/resources/components/Dashboard/Commerce/CommerceVariantsTable.stx +3 -5
  117. package/resources/components/Dashboard/Commerce/Delivery/CourierDialog.stx +1 -1
  118. package/resources/components/Dashboard/Commerce/Delivery/CouriersDashboard.stx +1 -1
  119. package/resources/components/Dashboard/Commerce/Delivery/CouriersTable.stx +2 -2
  120. package/resources/components/Dashboard/Commerce/Delivery/DeliveryOverviewDashboard.stx +44 -52
  121. package/resources/components/Dashboard/Commerce/Delivery/DeliveryPagination.stx +2 -2
  122. package/resources/components/Dashboard/Commerce/Delivery/DeliveryRouteDialog.stx +1 -1
  123. package/resources/components/Dashboard/Commerce/Delivery/DeliveryRoutesDashboard.stx +1 -1
  124. package/resources/components/Dashboard/Commerce/Delivery/DeliveryRoutesTable.stx +2 -2
  125. package/resources/components/Dashboard/Commerce/Delivery/DigitalDeliveriesDashboard.stx +1 -1
  126. package/resources/components/Dashboard/Commerce/Delivery/DigitalDeliveryTable.stx +2 -2
  127. package/resources/components/Dashboard/Commerce/Delivery/LicenseKeyDialog.stx +3 -3
  128. package/resources/components/Dashboard/Commerce/Delivery/LicenseKeysDashboard.stx +1 -1
  129. package/resources/components/Dashboard/Commerce/Delivery/LicenseKeysTable.stx +2 -2
  130. package/resources/components/Dashboard/Commerce/Delivery/ShippingMethodsDashboard.stx +1 -1
  131. package/resources/components/Dashboard/Commerce/Delivery/ShippingMethodsTable.stx +2 -2
  132. package/resources/components/Dashboard/Commerce/Delivery/ShippingRateDialog.stx +2 -2
  133. package/resources/components/Dashboard/Commerce/Delivery/ShippingRatesDashboard.stx +1 -1
  134. package/resources/components/Dashboard/Commerce/Delivery/ShippingRatesTable.stx +2 -2
  135. package/resources/components/Dashboard/Commerce/Delivery/ShippingZoneDialog.stx +1 -1
  136. package/resources/components/Dashboard/Commerce/Delivery/ShippingZonesDashboard.stx +1 -1
  137. package/resources/components/Dashboard/Commerce/Delivery/ShippingZonesTable.stx +4 -8
  138. package/resources/components/Dashboard/Commerce/PaymentDetailsDialog.stx +1 -3
  139. package/resources/components/Dashboard/Commerce/PrintDeviceBreakdown.stx +9 -15
  140. package/resources/components/Dashboard/Commerce/PrintDeviceDialog.stx +1 -1
  141. package/resources/components/Dashboard/Commerce/PrintDevicesDashboard.stx +3 -3
  142. package/resources/components/Dashboard/Commerce/PrintDevicesTable.stx +3 -3
  143. package/resources/components/Dashboard/Commerce/PrintLogBreakdown.stx +3 -9
  144. package/resources/components/Dashboard/Commerce/PrintLogDetailsDialog.stx +1 -1
  145. package/resources/components/Dashboard/Commerce/PrintLogsDashboard.stx +4 -4
  146. package/resources/components/Dashboard/Commerce/PrintLogsTable.stx +8 -10
  147. package/resources/components/Dashboard/Commerce/ProductWaitlistDashboard.stx +37 -109
  148. package/resources/components/Dashboard/Commerce/ProductWaitlistEntryDialog.stx +3 -3
  149. package/resources/components/Dashboard/Commerce/ProductWaitlistTable.stx +2 -2
  150. package/resources/components/Dashboard/Commerce/RestaurantWaitlistDashboard.stx +38 -112
  151. package/resources/components/Dashboard/Commerce/RestaurantWaitlistEntryDialog.stx +2 -2
  152. package/resources/components/Dashboard/Commerce/RestaurantWaitlistTable.stx +2 -2
  153. package/resources/components/Dashboard/Content/AuthorsDashboard.stx +4 -4
  154. package/resources/components/Dashboard/Content/BlogDashboard.stx +4 -4
  155. package/resources/components/Dashboard/Content/CommentsDashboard.stx +36 -83
  156. package/resources/components/Dashboard/Content/ContentDashboard.stx +12 -14
  157. package/resources/components/Dashboard/Content/ContentTaxonomyDashboard.stx +2 -2
  158. package/resources/components/Dashboard/Content/FileManagerDashboard.stx +8 -12
  159. package/resources/components/Dashboard/Content/FileStoragePanel.stx +6 -10
  160. package/resources/components/Dashboard/Content/FileUploadDialog.stx +1 -3
  161. package/resources/components/Dashboard/Content/PagesDashboard.stx +39 -78
  162. package/resources/components/Dashboard/Content/PostEditorDialog.stx +4 -8
  163. package/resources/components/Dashboard/Content/PostsDashboard.stx +44 -85
  164. package/resources/components/Dashboard/Content/SeoDashboard.stx +5 -4
  165. package/resources/components/Dashboard/Data/DataRecords.stx +140 -12
  166. package/resources/components/Dashboard/Deployments/DeploymentList.stx +4 -4
  167. package/resources/components/Dashboard/Deployments/DeploymentTable.stx +3 -1
  168. package/resources/components/Dashboard/Elements/DropdownNavigation.stx +5 -7
  169. package/resources/components/Dashboard/Email/CapturedMailDashboard.stx +1 -3
  170. package/resources/components/Dashboard/Email/CapturedMailList.stx +18 -20
  171. package/resources/components/Dashboard/Email/EmailActivityDashboard.stx +24 -28
  172. package/resources/components/Dashboard/Email/EmailSettingsList.stx +6 -8
  173. package/resources/components/Dashboard/Email/EmailSettingsNavigation.stx +10 -12
  174. package/resources/components/Dashboard/Email/EmailSidebar.stx +33 -37
  175. package/resources/components/Dashboard/Email/InboxMessageDetail.stx +1 -1
  176. package/resources/components/Dashboard/Email/InboxMessageList.stx +16 -18
  177. package/resources/components/Dashboard/Email/InboxSettingsDashboard.stx +1 -1
  178. package/resources/components/Dashboard/Environment/EnvironmentDashboard.stx +2 -2
  179. package/resources/components/Dashboard/GlobalSearch.stx +19 -21
  180. package/resources/components/Dashboard/Home/DashboardHome.stx +8 -1
  181. package/resources/components/Dashboard/Infrastructure/CloudDashboard.stx +1 -1
  182. package/resources/components/Dashboard/Infrastructure/DnsDashboard.stx +27 -13
  183. package/resources/components/Dashboard/Infrastructure/LogsDashboard.stx +1 -1
  184. package/resources/components/Dashboard/Infrastructure/MailboxesDashboard.stx +46 -8
  185. package/resources/components/Dashboard/Infrastructure/ServerlessDashboard.stx +1 -1
  186. package/resources/components/Dashboard/Infrastructure/ServersDashboard.stx +1 -1
  187. package/resources/components/Dashboard/Jobs/JobDetail.stx +1 -1
  188. package/resources/components/Dashboard/Jobs/JobHistory.stx +44 -57
  189. package/resources/components/Dashboard/Jobs/JobTable.stx +23 -25
  190. package/resources/components/Dashboard/Kanban/KanbanCardDialog.stx +1 -1
  191. package/resources/components/Dashboard/Library/ComponentsDashboard.stx +1 -1
  192. package/resources/components/Dashboard/Management/AssignmentDrawer.stx +5 -7
  193. package/resources/components/Dashboard/Management/PermissionsDashboard.stx +35 -43
  194. package/resources/components/Dashboard/Marketing/AbandonedCartsDashboard.stx +11 -13
  195. package/resources/components/Dashboard/Marketing/CampaignDialog.stx +1 -3
  196. package/resources/components/Dashboard/Marketing/CampaignsDashboard.stx +2 -2
  197. package/resources/components/Dashboard/Marketing/CampaignsTable.stx +2 -2
  198. package/resources/components/Dashboard/Marketing/MarketingListsDashboard.stx +1 -1
  199. package/resources/components/Dashboard/Marketing/MarketingListsTable.stx +2 -2
  200. package/resources/components/Dashboard/Marketing/SocialPostDialog.stx +1 -3
  201. package/resources/components/Dashboard/Marketing/SocialPostsDashboard.stx +2 -2
  202. package/resources/components/Dashboard/Marketing/SocialPostsTable.stx +2 -2
  203. package/resources/components/Dashboard/Models/ModelRecordActions.stx +11 -2
  204. package/resources/components/Dashboard/Models/ModelRecordCreate.stx +193 -0
  205. package/resources/components/Dashboard/Models/ModelRecordDetail.stx +144 -0
  206. package/resources/components/Dashboard/Models/ModelRecordEdit.stx +176 -0
  207. package/resources/components/Dashboard/Models/ModelRecordsDashboard.stx +52 -186
  208. package/resources/components/Dashboard/Models/ModelsOverview.stx +2 -4
  209. package/resources/components/Dashboard/Monitoring/ErrorDashboard.stx +47 -81
  210. package/resources/components/Dashboard/Monitoring/ErrorTable.stx +4 -2
  211. package/resources/components/Dashboard/NotFoundDashboard.stx +4 -4
  212. package/resources/components/Dashboard/Notifications/NotificationDeliveryHistory.stx +43 -77
  213. package/resources/components/Dashboard/Notifications/NotificationDeliveryOverview.stx +15 -17
  214. package/resources/components/Dashboard/Notifications/NotificationDeliveryTable.stx +1 -1
  215. package/resources/components/Dashboard/Operations/AuditDashboard.stx +1 -1
  216. package/resources/components/Dashboard/Operations/ChangeDashboard.stx +1 -1
  217. package/resources/components/Dashboard/Operations/IncidentDashboard.stx +1 -1
  218. package/resources/components/Dashboard/Operations/MigrationDashboard.stx +2 -2
  219. package/resources/components/Dashboard/Operations/RecoveryDashboard.stx +1 -1
  220. package/resources/components/Dashboard/Operations/SchedulerDashboard.stx +1 -1
  221. package/resources/components/Dashboard/Queries/QueryDashboard.stx +60 -86
  222. package/resources/components/Dashboard/Queries/QueryDetail.stx +5 -9
  223. package/resources/components/Dashboard/Realtime/RealtimeDashboard.stx +6 -8
  224. package/resources/components/Dashboard/Remote/RemoteConsole.stx +14 -20
  225. package/resources/components/Dashboard/Settings/AppearanceSettingsDashboard.stx +48 -54
  226. package/resources/components/Dashboard/Settings/MailSettingsDashboard.stx +8 -8
  227. package/resources/components/Dashboard/Settings/SettingsDashboard.stx +43 -47
  228. package/resources/components/Dashboard/Teams/TeamInvitationDashboard.stx +2 -2
  229. package/resources/components/Dashboard/UI/ActivityTable.stx +2 -1
  230. package/resources/components/Dashboard/UI/Button.stx +15 -0
  231. package/resources/components/Dashboard/UI/MetricCards.stx +5 -7
  232. package/resources/components/Dashboard/UI/Pagination.stx +3 -5
  233. package/resources/components/Dashboard/UI/QuickLinks.stx +2 -2
  234. package/resources/components/Dashboard/UI/Select.stx +1 -0
  235. package/resources/components/Dashboard/UI/Table.stx +139 -96
  236. package/resources/components/Dashboard/UI/Tabs.stx +18 -20
  237. package/routes/dashboard-api.ts +2 -0
  238. package/routes/dashboard.ts +246 -253
  239. package/routes/storefront.ts +31 -0
  240. package/stx-components-plugin.ts +12 -1
  241. package/views/dashboard/content/categories/index.stx +1 -1
  242. package/views/dashboard/content/tags/index.stx +1 -1
  243. package/views/dashboard/layouts/default.stx +27 -12
  244. package/views/dashboard/models/[model]/[id]/edit.stx +8 -0
  245. package/views/dashboard/models/[model]/[id].stx +8 -0
  246. package/views/dashboard/models/[model]/create.stx +8 -0
  247. package/resources/components/Dashboard/CreateRecordModal.stx +0 -138
  248. package/resources/components/Dashboard/Models/EditRecordModal.stx +0 -81
@@ -72,9 +72,7 @@ function submit(): void {
72
72
  <input ref="dashboardFileUploadInput" name="files" type="file" class="sr-only" multiple @change="handleFileSelection($event)" />
73
73
  </label>
74
74
  <ul :if="files().length" class="overflow-y-auto mt-4 space-y-1 max-h-32 text-sm">
75
- <template :for="file in files">
76
- <li class="flex gap-4 items-center justify-between px-3 py-2 bg-stone-50 dark:bg-neutral-900 rounded-lg"><span class="text-stone-700 truncate dark:text-neutral-200">{{ file.name }}</span><span class="flex-shrink-0 font-mono text-stone-500 text-xs dark:text-neutral-500">{{ formatFileSize(file.size) }}</span></li>
77
- </template>
75
+ <li :for="file in files" class="flex gap-4 items-center justify-between px-3 py-2 bg-stone-50 dark:bg-neutral-900 rounded-lg"><span class="text-stone-700 truncate dark:text-neutral-200">{{ file.name }}</span><span class="flex-shrink-0 font-mono text-stone-500 text-xs dark:text-neutral-500">{{ formatFileSize(file.size) }}</span></li>
78
76
  </ul>
79
77
  </form>
80
78
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  <script client>
4
4
  import { dashboardApi } from '../../../../functions/dashboard-api'
5
+ import { useServerList } from '../../../../functions/dashboard-list'
5
6
  import { pushToast } from '../../../../functions/toasts'
6
7
 
7
8
  interface PageRecord {
@@ -19,9 +20,6 @@ interface PageDraft {
19
20
  published: boolean
20
21
  }
21
22
 
22
- const pages = state<PageRecord[]>([])
23
- const loading = state(true)
24
- const loadError = state('')
25
23
  const formOpen = state(false)
26
24
  const editingPage = state<PageRecord | null>(null)
27
25
  const saving = state(false)
@@ -30,20 +28,11 @@ const deletingPage = state<PageRecord | null>(null)
30
28
  const deleting = state(false)
31
29
  const deleteError = state('')
32
30
 
33
- // The list is paged, searched and sorted by the server, and these are what
34
- // it was last asked for (stacksjs/stacks#3192). The cards count every page.
35
- const listPage = state(1)
36
- const perPage = state(25)
37
- const search = state('')
38
- const sort = state('')
39
- const sortDirection = state('asc')
40
- const total = state(0)
31
+ // The cards count every page (stacksjs/stacks#3192).
41
32
  const allCount = state(0)
42
33
  const viewCount = state(0)
43
34
  const conversionCount = state(0)
44
35
  const newestTitle = state('')
45
- let listRequestId = 0
46
- let searchTimer: ReturnType<typeof setTimeout> | undefined
47
36
 
48
37
  /** The server's name for each sortable column. */
49
38
  const SORT_KEYS: Record<string, string> = { title: 'title', publishState: 'published' }
@@ -78,13 +67,13 @@ const COLUMNS = [
78
67
  ]
79
68
 
80
69
  const ROW_ACTIONS = [
81
- { action: 'edit', label: 'Edit page', icon: 'i-hugeicons-edit-02' },
82
- { action: 'delete', label: 'Delete page', icon: 'i-hugeicons-delete-02', class: 'text-red-500' },
70
+ { action: 'edit', label: 'Edit page' },
71
+ { action: 'delete', label: 'Delete page' },
83
72
  ]
84
73
 
85
74
  /** The rows are the page the server chose; the cells each read a field, so derive them. */
86
75
  function visiblePages(): PageRecord[] {
87
- return pages().map(page => ({
76
+ return records().map(page => ({
88
77
  ...page,
89
78
  viewsLabel: `${formatNumber(page.views)} views`,
90
79
  conversionsLabel: `${formatNumber(page.conversions)} conversions`,
@@ -123,77 +112,49 @@ interface PageListResponse {
123
112
  newestTitle?: string
124
113
  }
125
114
 
126
- function listQuery(): string {
127
- const params = new URLSearchParams({ page: String(listPage()), per_page: String(perPage()) })
128
- if (search())
129
- params.set('search', search())
130
- if (sort()) {
131
- params.set('sort', sort())
132
- params.set('direction', sortDirection())
133
- }
134
- return params.toString()
135
- }
136
-
137
- async function loadPages(): Promise<void> {
138
- // Only the newest request may land: typing, paging and sorting can each
139
- // start one while another is still out.
140
- const requestId = ++listRequestId
141
- loading.set(true)
142
- loadError.set('')
143
- try {
144
- const data = await dashboardApi<PageListResponse>(`/api/dashboard/pages?${listQuery()}`)
145
- if (requestId !== listRequestId)
146
- return
115
+ // The server pages, searches and sorts (stacksjs/stacks#3192); useServerList
116
+ // keeps the request order, paging, header sort and search debounce this page
117
+ // used to keep itself. Unsorted is newest first, which the server reads as
118
+ // created_at descending.
119
+ const {
120
+ records,
121
+ total,
122
+ page: listPage,
123
+ perPage,
124
+ search,
125
+ loading,
126
+ loadError,
127
+ load,
128
+ changePage,
129
+ changePageSize,
130
+ changeSort,
131
+ } = useServerList<PageRecord>({
132
+ fetch: async (query) => {
133
+ const data = await dashboardApi<PageListResponse>(`/api/dashboard/pages?${query}`)
147
134
  if (!Array.isArray(data.pages))
148
135
  throw new TypeError('Pages were not returned in the expected shape.')
149
- pages.set(data.pages.map(normalize))
150
- total.set(Number(data.total || 0))
151
- // The server moves back to the last page when a delete or a narrower
152
- // search leaves this one past the end.
153
- listPage.set(Number(data.page || 1))
136
+ return { ...data, records: data.pages.map(normalize) }
137
+ },
138
+ defaultSort: { sort: 'created_at', direction: 'desc' },
139
+ columnSorts: SORT_KEYS,
140
+ searchParam: 'search',
141
+ onLoad: (result) => {
142
+ const data = result as PageListResponse
154
143
  allCount.set(Number(data.allCount || 0))
155
144
  viewCount.set(Number(data.totalViews || 0))
156
145
  conversionCount.set(Number(data.totalConversions || 0))
157
146
  newestTitle.set(String(data.newestTitle || ''))
158
- }
159
- catch (error) {
160
- if (requestId !== listRequestId)
161
- return
162
- loadError.set(error instanceof Error ? error.message : String(error))
163
- pushToast('error', 'Could not load pages', { detail: loadError() })
164
- }
165
- finally {
166
- if (requestId === listRequestId)
167
- loading.set(false)
168
- }
169
- }
170
-
171
- function changePage(next: number): void {
172
- listPage.set(next)
173
- void loadPages()
174
- }
147
+ },
148
+ onError: error => pushToast('error', 'Could not load pages', { detail: error instanceof Error ? error.message : String(error) }),
149
+ })
175
150
 
176
- function changePageSize(size: number): void {
177
- perPage.set(size)
178
- listPage.set(1)
179
- void loadPages()
151
+ function loadPages(): Promise<void> {
152
+ return load()
180
153
  }
181
154
 
155
+ /** The table's own search box; useServerList waits for typing to pause. */
182
156
  function changeSearch(term: string): void {
183
- if (searchTimer)
184
- clearTimeout(searchTimer)
185
- searchTimer = setTimeout(() => {
186
- search.set(String(term || '').trim())
187
- listPage.set(1)
188
- void loadPages()
189
- }, 250)
190
- }
191
-
192
- function changeSort(next: { key: string, direction: string }): void {
193
- sort.set(SORT_KEYS[next.key] || '')
194
- sortDirection.set(next.direction === 'desc' ? 'desc' : 'asc')
195
- listPage.set(1)
196
- void loadPages()
157
+ search.set(String(term || ''))
197
158
  }
198
159
 
199
160
  function openCreate(): void {
@@ -276,7 +237,7 @@ onMount(() => {
276
237
 
277
238
  <div class="space-y-6">
278
239
  <header class="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
279
- <div><p class="font-semibold text-blue-600 text-xs tracking-wide uppercase dark:text-blue-400">CMS</p><h1 class="mt-1 font-bold text-2xl text-gray-900 dark:text-white">Pages</h1><p class="mt-1 text-gray-500 text-sm dark:text-neutral-400">Manage persisted CMS pages, templates, and publishing state.</p></div>
240
+ <div><p class="font-semibold text-blue-600 text-xs tracking-wide uppercase dark:text-blue-400">Content</p><h1 class="mt-1 font-bold text-2xl text-gray-900 dark:text-white">Pages</h1><p class="mt-1 text-gray-500 text-sm dark:text-neutral-400">Create your site's pages, choose their templates, and decide when they go live.</p></div>
280
241
  <div class="flex gap-2"><Button :loading="loading()" variant="secondary" @click="loadPages()"><span :if="!loading()" aria-hidden="true" class="h-4 w-4 i-hugeicons-refresh"></span>Refresh</Button><Button @click="openCreate()"><span aria-hidden="true" class="h-4 w-4 i-hugeicons-add-01"></span>New page</Button></div>
281
242
  </header>
282
243
 
@@ -111,7 +111,7 @@ function submit(): void {
111
111
  <Modal
112
112
  :isOpen="open()"
113
113
  :title="editing() ? 'Edit post' : 'New post'"
114
- description="Content, ownership, and taxonomies are persisted together."
114
+ description="The text, author, categories and tags are saved together."
115
115
  size="xl"
116
116
  :closable="!busy()"
117
117
  @close="close"
@@ -134,7 +134,7 @@ function submit(): void {
134
134
  <span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Author</span>
135
135
  <select x-model="authorId" name="author_id" class="mt-1 px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700">
136
136
  <option value="">No author</option>
137
- <template :for="author in authors()"><option :value="author.id">{{ author.name }} ({{ author.email }})</option></template>
137
+ <option :for="author in authors()" :value="author.id">{{ author.name }} ({{ author.email }})</option>
138
138
  </select>
139
139
  </label>
140
140
  <label class="flex gap-3 items-center self-end px-3 py-2 min-h-10 bg-gray-50 dark:bg-neutral-900/60 border border-gray-200 rounded-md dark:border-neutral-700">
@@ -167,18 +167,14 @@ function submit(): void {
167
167
  <legend class="px-1 font-semibold text-gray-700 text-sm dark:text-neutral-200">Categories, {{ categoryIds().length }} selected</legend>
168
168
  <div :if="categories().length === 0" class="text-gray-500 text-sm dark:text-neutral-400">No categories available.</div>
169
169
  <div :else class="grid gap-2">
170
- <template :for="categoryOption in categories()">
171
- <label class="flex gap-2 items-center"><input x-model="categoryIds" name="category_ids" type="checkbox" :value="categoryOption.id" class="h-4 w-4 text-blue-600 border-gray-300 rounded" /><span class="text-gray-700 text-sm dark:text-neutral-200">{{ categoryOption.name }}</span></label>
172
- </template>
170
+ <label :for="categoryOption in categories()" class="flex gap-2 items-center"><input x-model="categoryIds" name="category_ids" type="checkbox" :value="categoryOption.id" class="h-4 w-4 text-blue-600 border-gray-300 rounded" /><span class="text-gray-700 text-sm dark:text-neutral-200">{{ categoryOption.name }}</span></label>
173
171
  </div>
174
172
  </fieldset>
175
173
  <fieldset class="p-4 border border-gray-200 rounded-lg dark:border-neutral-700">
176
174
  <legend class="px-1 font-semibold text-gray-700 text-sm dark:text-neutral-200">Tags, {{ tagIds().length }} selected</legend>
177
175
  <div :if="tags().length === 0" class="text-gray-500 text-sm dark:text-neutral-400">No tags available.</div>
178
176
  <div :else class="grid gap-2 sm:grid-cols-2">
179
- <template :for="tag in tags()">
180
- <label class="flex gap-2 items-center"><input x-model="tagIds" name="tag_ids" type="checkbox" :value="tag.id" class="h-4 w-4 text-blue-600 border-gray-300 rounded" /><span class="text-gray-700 text-sm dark:text-neutral-200">{{ tag.name }}</span></label>
181
- </template>
177
+ <label :for="tag in tags()" class="flex gap-2 items-center"><input x-model="tagIds" name="tag_ids" type="checkbox" :value="tag.id" class="h-4 w-4 text-blue-600 border-gray-300 rounded" /><span class="text-gray-700 text-sm dark:text-neutral-200">{{ tag.name }}</span></label>
182
178
  </div>
183
179
  </fieldset>
184
180
  </div>
@@ -8,6 +8,7 @@ export const blogUrl = publicApplicationUrl('/blog')
8
8
 
9
9
  <script client>
10
10
  import { dashboardApi } from '../../../../functions/dashboard-api'
11
+ import { useServerList } from '../../../../functions/dashboard-list'
11
12
  import { pushToast } from '../../../../functions/toasts'
12
13
 
13
14
  type PostStatus = 'draft' | 'published' | 'archived'
@@ -39,29 +40,17 @@ interface PostDraft {
39
40
  tagIds: string[]
40
41
  }
41
42
 
42
- const posts = state<PostRecord[]>([])
43
43
  const categories = state<OptionRecord[]>([])
44
44
  const tags = state<OptionRecord[]>([])
45
45
  const authors = state<AuthorRecord[]>([])
46
- const loading = state(true)
47
- const loadError = state('')
48
46
  const statusFilter = state('all')
49
47
 
50
- // The list is paged, searched and sorted by the server, and these are what
51
- // it was last asked for (stacksjs/stacks#3191). The cards count every post.
52
- const page = state(1)
53
- const perPage = state(25)
54
- const search = state('')
55
- const sort = state('')
56
- const sortDirection = state('asc')
57
- const total = state(0)
48
+ // The cards count every post (stacksjs/stacks#3191).
58
49
  const allCount = state(0)
59
50
  const publishedCount = state(0)
60
51
  const draftCount = state(0)
61
52
  const archivedCount = state(0)
62
53
  const totalViewCount = state(0)
63
- let listRequestId = 0
64
- let searchTimer: ReturnType<typeof setTimeout> | undefined
65
54
 
66
55
  const loadedContent = state('')
67
56
  const contentLoading = state(false)
@@ -132,8 +121,8 @@ const COLUMNS = [
132
121
  ]
133
122
 
134
123
  const ROW_ACTIONS = [
135
- { action: 'edit', label: 'Edit post', icon: 'i-hugeicons-edit-02' },
136
- { action: 'delete', label: 'Delete post', icon: 'i-hugeicons-delete-02', class: 'text-red-500' },
124
+ { action: 'edit', label: 'Edit post' },
125
+ { action: 'delete', label: 'Delete post' },
137
126
  ]
138
127
 
139
128
  /**
@@ -142,7 +131,7 @@ const ROW_ACTIONS = [
142
131
  * back into the component.
143
132
  */
144
133
  function visiblePosts(): PostRecord[] {
145
- return posts()
134
+ return records()
146
135
  .map(post => ({
147
136
  ...post,
148
137
  summaryLabel: post.excerpt || post.preview,
@@ -198,89 +187,59 @@ interface PostPageResponse {
198
187
  totalViews?: number
199
188
  }
200
189
 
201
- function listQuery(): string {
202
- const params = new URLSearchParams({ page: String(page()), per_page: String(perPage()) })
203
- if (search())
204
- params.set('search', search())
205
- if (statusFilter() !== 'all')
206
- params.set('status', statusFilter())
207
- if (sort()) {
208
- params.set('sort', sort())
209
- params.set('direction', sortDirection())
210
- }
211
- return params.toString()
212
- }
213
-
214
- async function loadPosts(): Promise<void> {
215
- // Only the newest request may land: typing, paging and filtering can each
216
- // start one while another is still out.
217
- const requestId = ++listRequestId
218
- loading.set(true)
219
- loadError.set('')
220
- try {
221
- const data = await dashboardApi<PostPageResponse>(`/api/dashboard/posts?${listQuery()}`)
222
- if (requestId !== listRequestId)
223
- return
190
+ // The server pages, searches, filters and sorts (stacksjs/stacks#3191);
191
+ // useServerList keeps the request order, paging, header sort and search
192
+ // debounce this page used to keep itself. Unsorted is newest first, which the
193
+ // server reads as created_at descending.
194
+ const {
195
+ records,
196
+ total,
197
+ page,
198
+ perPage,
199
+ search,
200
+ loading,
201
+ loadError,
202
+ load,
203
+ changePage,
204
+ changePageSize,
205
+ changeSort,
206
+ } = useServerList<PostRecord>({
207
+ fetch: async (query) => {
208
+ const data = await dashboardApi<PostPageResponse>(`/api/dashboard/posts?${query}`)
224
209
  if (!Array.isArray(data.posts) || !Array.isArray(data.categories) || !Array.isArray(data.tags) || !Array.isArray(data.authors))
225
210
  throw new TypeError('Posts were not returned in the expected shape.')
226
- posts.set(data.posts.map(normalizePost))
227
- categories.set(data.categories.map(normalizeOption))
228
- tags.set(data.tags.map(normalizeOption))
229
- authors.set(data.authors.map(normalizeAuthor))
230
- total.set(Number(data.total || 0))
231
- // The server moves back to the last page when a delete or a narrower
232
- // search leaves this one past the end.
233
- page.set(Number(data.page || 1))
211
+ return { ...data, records: data.posts.map(normalizePost) }
212
+ },
213
+ defaultSort: { sort: 'created_at', direction: 'desc' },
214
+ // The table's sortable columns are named as the server sorts them.
215
+ columnSorts: { title: 'title', status: 'status', views: 'views' },
216
+ filters: () => ({ status: statusFilter() }),
217
+ searchParam: 'search',
218
+ onLoad: (result) => {
219
+ const data = result as PostPageResponse
220
+ categories.set((data.categories ?? []).map(normalizeOption))
221
+ tags.set((data.tags ?? []).map(normalizeOption))
222
+ authors.set((data.authors ?? []).map(normalizeAuthor))
234
223
  allCount.set(Number(data.allCount || 0))
235
224
  publishedCount.set(Number(data.publishedCount || 0))
236
225
  draftCount.set(Number(data.draftCount || 0))
237
226
  archivedCount.set(Number(data.archivedCount || 0))
238
227
  totalViewCount.set(Number(data.totalViews || 0))
239
- }
240
- catch (error) {
241
- if (requestId !== listRequestId)
242
- return
243
- loadError.set(error instanceof Error ? error.message : String(error))
244
- pushToast('error', 'Could not load posts', { detail: loadError() })
245
- }
246
- finally {
247
- if (requestId === listRequestId)
248
- loading.set(false)
249
- }
250
- }
251
-
252
- function changePage(next: number): void {
253
- page.set(next)
254
- void loadPosts()
255
- }
228
+ },
229
+ onError: error => pushToast('error', 'Could not load posts', { detail: error instanceof Error ? error.message : String(error) }),
230
+ })
256
231
 
257
- function changePageSize(size: number): void {
258
- perPage.set(size)
259
- page.set(1)
260
- void loadPosts()
232
+ function loadPosts(): Promise<void> {
233
+ return load()
261
234
  }
262
235
 
236
+ /** The table's own search box; useServerList waits for typing to pause. */
263
237
  function changeSearch(term: string): void {
264
- if (searchTimer)
265
- clearTimeout(searchTimer)
266
- searchTimer = setTimeout(() => {
267
- search.set(String(term || '').trim())
268
- page.set(1)
269
- void loadPosts()
270
- }, 250)
271
- }
272
-
273
- function changeSort(next: { key: string, direction: string }): void {
274
- sort.set(next.key || '')
275
- sortDirection.set(next.direction === 'desc' ? 'desc' : 'asc')
276
- page.set(1)
277
- void loadPosts()
238
+ search.set(String(term || ''))
278
239
  }
279
240
 
280
241
  function changeStatus(event: Event): void {
281
242
  statusFilter.set((event.target as HTMLSelectElement).value)
282
- page.set(1)
283
- void loadPosts()
284
243
  }
285
244
 
286
245
  async function loadEditorContent(post: PostRecord): Promise<void> {
@@ -391,7 +350,7 @@ onMount(() => { void loadPosts() })
391
350
 
392
351
  <div class="space-y-6">
393
352
  <header class="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
394
- <div><p class="font-semibold text-blue-600 text-xs tracking-wide uppercase dark:text-blue-400">CMS</p><h1 class="mt-1 font-bold text-2xl text-gray-900 dark:text-white">Posts</h1><p class="mt-1 text-gray-500 text-sm dark:text-neutral-400">Manage persisted articles, publishing, authors, and native taxonomies.</p></div>
353
+ <div><p class="font-semibold text-blue-600 text-xs tracking-wide uppercase dark:text-blue-400">Content</p><h1 class="mt-1 font-bold text-2xl text-gray-900 dark:text-white">Posts</h1><p class="mt-1 text-gray-500 text-sm dark:text-neutral-400">Write and publish articles, and manage their authors, categories and tags.</p></div>
395
354
  <div class="flex flex-wrap gap-2"><Button href="{{ blogUrl }}" target="_blank" rel="noreferrer" variant="secondary"><span aria-hidden="true" class="h-4 w-4 i-hugeicons-view"></span>View blog</Button><Button :loading="loading()" variant="secondary" @click="loadPosts()"><span :if="!loading()" aria-hidden="true" class="h-4 w-4 i-hugeicons-refresh"></span>Refresh</Button><Button @click="openCreate()"><span aria-hidden="true" class="h-4 w-4 i-hugeicons-add-01"></span>New post</Button></div>
396
355
  </header>
397
356
 
@@ -124,7 +124,7 @@ const filteredEntries = derived(() => {
124
124
  * on a derived band and `badgeLabelKey` puts the number itself in the pill.
125
125
  */
126
126
  const SEO_ROW_ACTIONS = [
127
- { action: 'edit', label: 'Edit SEO for', icon: 'i-hugeicons-edit-02' },
127
+ { action: 'edit', label: 'Edit SEO for' },
128
128
  ]
129
129
 
130
130
  const SEO_COLUMNS = [
@@ -227,10 +227,10 @@ void loadEntries()
227
227
  </script>
228
228
 
229
229
  <template>
230
- <div class="mx-auto pb-12 pt-6 px-6 space-y-6 max-w-7xl">
230
+ <div class="flex flex-col gap-6 mx-auto pb-12 pt-6 px-6 max-w-7xl">
231
231
  <PageHeader
232
232
  title="SEO"
233
- description="Review model-backed search metadata for every CMS post"
233
+ description="How every post appears in search results: its title, description and focus keyword"
234
234
  />
235
235
 
236
236
  <div class="px-4 py-3 text-blue-800 text-sm dark:text-blue-200 bg-blue-50 dark:bg-blue-500/10 border border-blue-200 rounded-lg dark:border-blue-500/20">
@@ -299,6 +299,7 @@ void loadEntries()
299
299
  adding one to a working table, watching `/dependencies` stop
300
300
  responding, and removing it again. See stacksjs/stx#2101. --}}
301
301
  <Table
302
+ :framed="false"
302
303
  :columns="SEO_COLUMNS"
303
304
  :data="seoRows()"
304
305
  :loading="loading()"
@@ -306,7 +307,7 @@ void loadEntries()
306
307
  paginated
307
308
  :page-size="25"
308
309
  empty-title="No matching posts"
309
- empty-description="Adjust the search or score filter, or create a CMS post first."
310
+ empty-description="Adjust the search or score filter, or create a post first."
310
311
  :row-actions="SEO_ROW_ACTIONS"
311
312
  action-label-key="title"
312
313
  @row-action="openEdit($event.row)"