@stacksjs/defaults 0.75.529 → 0.75.535

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 +4 -4
  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
@@ -376,7 +376,7 @@ function formatTimestamp(iso: string | null | undefined): string {
376
376
  <span :if="cardLabels().length === 0" class="italic text-xs text-zinc-500 dark:text-zinc-400">None</span>
377
377
  </div>
378
378
 
379
- <div :if="showLabelPicker()" class="space-y-2">
379
+ <div :if="showLabelPicker()" class="flex flex-col gap-2">
380
380
  <div :for="label in allLabels" :class="`flex items-center gap-1 px-1 py-0.5 w-full rounded ${labelChipClass(label.color)}`">
381
381
  <button type="button" class="flex flex-1 items-center justify-between px-1 py-0.5 min-w-0 text-left text-xs rounded hover:opacity-90" :aria-pressed="String(cardLabels().some(cardLabel => cardLabel.id === label.id))" @click="toggleLabel(label.id)">
382
382
  <span class="truncate" :text="label.name"></span>
@@ -122,7 +122,7 @@ onMount(() => {
122
122
  <p class="font-semibold text-blue-600 text-xs tracking-wide uppercase dark:text-blue-400">Library</p>
123
123
  <h1 class="mt-1 font-bold text-2xl text-gray-900 dark:text-white">Components</h1>
124
124
  <p class="mt-1 text-gray-500 text-sm dark:text-neutral-400">
125
- STX component sources discovered from <span class="font-mono" :text="sourceRoot()"></span>.
125
+ The reusable interface pieces found in <span class="font-mono" :text="sourceRoot()"></span>, written in <abbr title="The Stacks template language: HTML with signals, directives and components" class="underline underline-offset-2 cursor-help decoration-dotted">STX</abbr>.
126
126
  </p>
127
127
  </div>
128
128
  <div class="flex gap-2">
@@ -63,25 +63,23 @@ function save(): void {
63
63
  <div :if="guardOptions().length > 0" class="px-5 py-3 border-b border-zinc-200 dark:border-zinc-800">
64
64
  <label for="assignment-guard" class="block mb-1.5 font-medium text-xs text-zinc-600 dark:text-zinc-400">Guard</label>
65
65
  <select id="assignment-guard" x-model="guardValue" name="guard" class="px-3 py-1.5 w-full text-sm text-zinc-900 dark:text-zinc-100 bg-white dark:bg-neutral-800 border border-zinc-300 rounded-md dark:border-zinc-700 focus:border-violet-500 focus:outline-none focus:ring-2 focus:ring-violet-500/20" @change="changeGuard">
66
- <template :for="option in guardOptions()">
67
- <option :value="option.value">{{ option.label }}</option>
68
- </template>
66
+ <option :for="option in guardOptions()" :value="option.value">{{ option.label }}</option>
69
67
  </select>
70
68
  </div>
71
69
 
72
- <div class="px-5 py-4 space-y-2">
70
+ <div class="flex flex-col gap-2 px-5 py-4">
73
71
  <div :if="loading()" class="flex gap-2 items-center py-6 text-sm text-zinc-500">
74
72
  <span class="h-4 w-4 animate-spin i-hugeicons-loading-03"></span>
75
73
  Loading assignments...
76
74
  </div>
77
75
  <div :if="!loading() && options().length === 0" class="text-sm text-zinc-500">{{ emptyMessage() }}</div>
78
- <template :if="!loading()" :for="option in options()">
79
- <label class="flex gap-2 items-center px-2 py-1.5 hover:bg-zinc-50 dark:hover:bg-neutral-800 rounded-md cursor-pointer">
76
+ <div :if="!loading()" class="contents">
77
+ <label :for="option in options()" class="flex gap-2 items-center px-2 py-1.5 hover:bg-zinc-50 dark:hover:bg-neutral-800 rounded-md cursor-pointer">
80
78
  <input name="assignments" type="checkbox" :value="option.name" :checked="selected().includes(option.name)" class="h-4 w-4 text-violet-600 border-zinc-300 rounded dark:border-zinc-700 focus:ring-violet-500" @change="toggle(option.name)" />
81
79
  <span class="text-sm text-zinc-900 dark:text-zinc-100">{{ option.name }}</span>
82
80
  <span class="text-xs text-zinc-500">{{ option.description || '' }}</span>
83
81
  </label>
84
- </template>
82
+ </div>
85
83
  </div>
86
84
 
87
85
  <template #footer>
@@ -391,20 +391,18 @@
391
391
  </tr>
392
392
  </thead>
393
393
  <tbody class="divide-y divide-zinc-200 dark:divide-zinc-800">
394
- <template :for="role in filteredRoles">
395
- <tr>
396
- <td class="px-5 py-2 font-medium text-sm text-zinc-900 dark:text-zinc-100">{{ role.name }}</td>
397
- <td class="px-5 py-2 text-xs text-zinc-500"><code>{{ role.guardName }}</code></td>
398
- <td class="px-5 py-2 text-sm text-zinc-600 dark:text-zinc-400">{{ role.description || '-' }}</td>
399
- <td class="px-5 py-2 text-xs text-zinc-500">{{ formatDate(role.createdAt) }}</td>
400
- <td class="px-5 py-2 text-right text-sm">
401
- <span class="inline-flex gap-1 justify-end">
402
- <Button variant="ghost" size="sm" @click="selectTab('matrix'); selectRole(role)">Permissions</Button>
403
- <Button variant="ghost" size="sm" @click="requestRoleDelete(role)"><span class="text-red-600 dark:text-red-400">Delete</span></Button>
404
- </span>
405
- </td>
406
- </tr>
407
- </template>
394
+ <tr :for="role in filteredRoles">
395
+ <td class="px-5 py-2 font-medium text-sm text-zinc-900 dark:text-zinc-100">{{ role.name }}</td>
396
+ <td class="px-5 py-2 text-xs text-zinc-500"><code>{{ role.guardName }}</code></td>
397
+ <td class="px-5 py-2 text-sm text-zinc-600 dark:text-zinc-400">{{ role.description || '-' }}</td>
398
+ <td class="px-5 py-2 text-xs text-zinc-500">{{ formatDate(role.createdAt) }}</td>
399
+ <td class="px-5 py-2 text-right text-sm">
400
+ <span class="inline-flex gap-1 justify-end">
401
+ <Button variant="ghost" size="sm" @click="selectTab('matrix'); selectRole(role)">Permissions</Button>
402
+ <Button variant="ghost" size="sm" @click="requestRoleDelete(role)"><span class="text-red-600 dark:text-red-400">Delete</span></Button>
403
+ </span>
404
+ </td>
405
+ </tr>
408
406
  </tbody>
409
407
  </table>
410
408
  </div>
@@ -441,17 +439,15 @@
441
439
  </tr>
442
440
  </thead>
443
441
  <tbody class="divide-y divide-zinc-200 dark:divide-zinc-800">
444
- <template :for="perm in filteredPermissions">
445
- <tr>
446
- <td class="px-5 py-2 font-medium text-sm text-zinc-900 dark:text-zinc-100">{{ perm.name }}</td>
447
- <td class="px-5 py-2 text-xs text-zinc-500"><code>{{ perm.guardName }}</code></td>
448
- <td class="px-5 py-2 text-sm text-zinc-600 dark:text-zinc-400">{{ perm.description || '-' }}</td>
449
- <td class="px-5 py-2 text-xs text-zinc-500">{{ formatDate(perm.createdAt) }}</td>
450
- <td class="px-5 py-2 text-right text-sm">
451
- <Button variant="ghost" size="sm" @click="requestPermissionDelete(perm)"><span class="text-red-600 dark:text-red-400">Delete</span></Button>
452
- </td>
453
- </tr>
454
- </template>
442
+ <tr :for="perm in filteredPermissions">
443
+ <td class="px-5 py-2 font-medium text-sm text-zinc-900 dark:text-zinc-100">{{ perm.name }}</td>
444
+ <td class="px-5 py-2 text-xs text-zinc-500"><code>{{ perm.guardName }}</code></td>
445
+ <td class="px-5 py-2 text-sm text-zinc-600 dark:text-zinc-400">{{ perm.description || '-' }}</td>
446
+ <td class="px-5 py-2 text-xs text-zinc-500">{{ formatDate(perm.createdAt) }}</td>
447
+ <td class="px-5 py-2 text-right text-sm">
448
+ <Button variant="ghost" size="sm" @click="requestPermissionDelete(perm)"><span class="text-red-600 dark:text-red-400">Delete</span></Button>
449
+ </td>
450
+ </tr>
455
451
  </tbody>
456
452
  </table>
457
453
  </div>
@@ -476,15 +472,13 @@
476
472
  </tr>
477
473
  </thead>
478
474
  <tbody class="divide-y divide-zinc-200 dark:divide-zinc-800">
479
- <template :for="u in filteredUsers">
480
- <tr>
481
- <td class="px-5 py-2 font-medium text-sm text-zinc-900 dark:text-zinc-100">{{ u.name || '-' }}</td>
482
- <td class="px-5 py-2 text-sm text-zinc-500">{{ u.email || '-' }}</td>
483
- <td class="px-5 py-2 text-right text-sm">
484
- <Button variant="ghost" size="sm" @click="selectUser(u)">Manage roles</Button>
485
- </td>
486
- </tr>
487
- </template>
475
+ <tr :for="u in filteredUsers">
476
+ <td class="px-5 py-2 font-medium text-sm text-zinc-900 dark:text-zinc-100">{{ u.name || '-' }}</td>
477
+ <td class="px-5 py-2 text-sm text-zinc-500">{{ u.email || '-' }}</td>
478
+ <td class="px-5 py-2 text-right text-sm">
479
+ <Button variant="ghost" size="sm" @click="selectUser(u)">Manage roles</Button>
480
+ </td>
481
+ </tr>
488
482
  </tbody>
489
483
  </table>
490
484
  </div>
@@ -498,15 +492,13 @@
498
492
  </div>
499
493
  <div :if="roles().length === 0" class="px-5 py-8 text-center text-sm text-zinc-500 bg-white dark:bg-neutral-900 border border-zinc-200 rounded-lg dark:border-zinc-800">No roles yet. Create one on the Roles tab.</div>
500
494
  <div :if="roles().length > 0" class="grid gap-3 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3">
501
- <template :for="role in roles">
502
- <button type="button" @click="selectRole(role)" class="block px-4 py-3 text-left bg-white dark:bg-neutral-900 border border-zinc-200 rounded-lg dark:border-zinc-800 hover:border-violet-300 dark:hover:border-violet-700 transition-colors">
503
- <div class="flex gap-2 items-center justify-between">
504
- <span class="font-medium text-sm text-zinc-900 dark:text-zinc-100">{{ role.name }}</span>
505
- <code class="text-[10px] text-zinc-500">{{ role.guardName }}</code>
506
- </div>
507
- <div class="mt-0.5 text-xs text-zinc-500">{{ role.description || 'No description' }}</div>
508
- </button>
509
- </template>
495
+ <button :for="role in roles" type="button" @click="selectRole(role)" class="block px-4 py-3 text-left bg-white dark:bg-neutral-900 border border-zinc-200 rounded-lg dark:border-zinc-800 hover:border-violet-300 dark:hover:border-violet-700 transition-colors">
496
+ <div class="flex gap-2 items-center justify-between">
497
+ <span class="font-medium text-sm text-zinc-900 dark:text-zinc-100">{{ role.name }}</span>
498
+ <code class="text-[10px] text-zinc-500">{{ role.guardName }}</code>
499
+ </div>
500
+ <div class="mt-0.5 text-xs text-zinc-500">{{ role.description || 'No description' }}</div>
501
+ </button>
510
502
  </div>
511
503
  </div>
512
504
  </div>
@@ -176,22 +176,20 @@ onMount(() => {
176
176
  <h2 class="font-semibold text-gray-900 text-sm dark:text-white">Recovery campaigns</h2>
177
177
  <p class="mt-1 text-gray-500 text-xs dark:text-neutral-400">Ordinary campaigns aimed at cold carts. They send, report and are edited on the campaigns screen like any other.</p>
178
178
  <ul class="mt-3 divide-gray-200 divide-y dark:divide-neutral-700">
179
- <template :for="campaign in campaigns">
180
- <li class="flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between py-3">
181
- <div>
182
- <p class="font-medium text-gray-900 text-sm dark:text-white">{{ campaign.name }}</p>
183
- <p class="mt-1 text-gray-500 text-xs dark:text-neutral-400">Carts idle {{ campaign.idleHours }}h or more<span :if="campaign.minimumValue > 0"> · {{ money(campaign.minimumValue) }} and up</span> · {{ campaignTiming(campaign) }}</p>
184
- </div>
185
- <div class="flex gap-3 items-center">
186
- <p class="text-gray-500 text-xs dark:text-neutral-400">{{ campaign.sentCount.toLocaleString() }} sent</p>
187
- <span class="inline-flex px-2 py-1 font-medium text-xs bg-gray-100 dark:bg-neutral-700 rounded-full">{{ campaign.status }}</span>
188
- </div>
189
- </li>
190
- </template>
179
+ <li :for="campaign in campaigns" class="flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between py-3">
180
+ <div>
181
+ <p class="font-medium text-gray-900 text-sm dark:text-white">{{ campaign.name }}</p>
182
+ <p class="mt-1 text-gray-500 text-xs dark:text-neutral-400">Carts idle {{ campaign.idleHours }}h or more<span :if="campaign.minimumValue > 0"> · {{ money(campaign.minimumValue) }} and up</span> · {{ campaignTiming(campaign) }}</p>
183
+ </div>
184
+ <div class="flex gap-3 items-center">
185
+ <p class="text-gray-500 text-xs dark:text-neutral-400">{{ campaign.sentCount.toLocaleString() }} sent</p>
186
+ <span class="inline-flex px-2 py-1 font-medium text-xs bg-gray-100 dark:bg-neutral-700 rounded-full">{{ campaign.status }}</span>
187
+ </div>
188
+ </li>
191
189
  </ul>
192
190
  </section>
193
191
 
194
- <section class="space-y-3">
192
+ <section class="flex flex-col gap-3">
195
193
  <div class="grid gap-3 grid-cols-1 sm:grid-cols-2 xl:grid-cols-4">
196
194
  <label><span class="sr-only">Search carts</span><input x-model="search" type="search" placeholder="Search by customer or product" class="px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-800 border border-gray-300 rounded-md dark:border-neutral-700" /></label>
197
195
  <label><span class="sr-only">Filter cart state</span><select x-model="stateFilter" class="px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-800 border border-gray-300 rounded-md dark:border-neutral-700"><option value="open">Still out there</option><option value="cold">Never chased</option><option value="chased">Already chased</option><option value="recovered">Recovered</option><option value="all">Everything</option></select></label>
@@ -173,9 +173,7 @@ function submit(): void {
173
173
  <span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Email list</span>
174
174
  <select x-model="emailListId" required 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">
175
175
  <option value="">Select a list</option>
176
- <template :for="list in lists">
177
- <option :value="list.id">{{ list.name }} - {{ list.activeMembers.toLocaleString() }} active</option>
178
- </template>
176
+ <option :for="list in lists" :value="list.id">{{ list.name }} - {{ list.activeMembers.toLocaleString() }} active</option>
179
177
  </select>
180
178
  </label>
181
179
  <label class="block sm:col-span-2">
@@ -280,12 +280,12 @@ onMount(() => {
280
280
  <article class="p-4 bg-white dark:bg-neutral-800 border border-gray-200 rounded-lg dark:border-neutral-700"><p class="text-gray-500 text-xs dark:text-neutral-400">Delivery issues</p><p class="mt-2 font-semibold text-2xl text-gray-900 dark:text-white">{{ summary().failedDeliveries.toLocaleString() }}</p><p class="mt-1 text-gray-500 text-xs dark:text-neutral-500">Failed, bounced, or complained</p></article>
281
281
  </section>
282
282
 
283
- <section class="space-y-3">
283
+ <section class="flex flex-col gap-3">
284
284
  <div class="grid gap-3 grid-cols-1 sm:grid-cols-2 xl:grid-cols-5">
285
285
  <label><span class="sr-only">Search campaigns</span><input x-model="search" type="search" placeholder="Search campaigns" class="px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-800 border border-gray-300 rounded-md dark:border-neutral-700" /></label>
286
286
  <label><span class="sr-only">Filter campaign type</span><select x-model="typeFilter" class="px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-800 border border-gray-300 rounded-md dark:border-neutral-700"><option value="all">All types</option><option value="email">Email</option><option value="sms">SMS</option><option value="push">Push</option><option value="social">Social</option><option value="multi-channel">Multi-channel</option></select></label>
287
287
  <label><span class="sr-only">Filter campaign status</span><select x-model="statusFilter" class="px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-800 border border-gray-300 rounded-md dark:border-neutral-700"><option value="all">All statuses</option><option value="draft">Draft</option><option value="scheduled">Scheduled</option><option value="sending">Sending</option><option value="sent">Sent</option><option value="active">Active</option><option value="completed">Completed</option><option value="paused">Paused</option><option value="cancelled">Cancelled</option><option value="failed">Failed</option><option value="archived">Archived</option></select></label>
288
- <label><span class="sr-only">Filter campaign list</span><select x-model="listFilter" class="px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-800 border border-gray-300 rounded-md dark:border-neutral-700"><option value="all">All email lists</option><template :for="list in lists"><option :value="list.id">{{ list.name }}</option></template></select></label>
288
+ <label><span class="sr-only">Filter campaign list</span><select x-model="listFilter" class="px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-800 border border-gray-300 rounded-md dark:border-neutral-700"><option value="all">All email lists</option><option :for="list in lists" :value="list.id">{{ list.name }}</option></select></label>
289
289
  <label><span class="sr-only">Sort campaigns</span><select x-model="sort" class="px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-800 border border-gray-300 rounded-md dark:border-neutral-700"><option value="newest">Newest</option><option value="name">Name</option><option value="audience">Largest audience</option><option value="sent">Most sent</option></select></label>
290
290
  </div>
291
291
  <CampaignsTable :sort-reset-key="sort()" :page-reset-key="viewKey()" :records="filteredRecords()" :loading="loading()" @edit="openEdit" @delete="openDelete" @deliver="openDelivery" />
@@ -69,8 +69,8 @@ const ROW_ACTIONS = [
69
69
  { action: 'schedule', label: 'Schedule', icon: 'i-hugeicons-calendar-03', when: { key: 'scheduleLabel', equals: 'schedule' } },
70
70
  { action: 'schedule', label: 'Reschedule', icon: 'i-hugeicons-calendar-03', when: { key: 'scheduleLabel', equals: 'reschedule' } },
71
71
  { action: 'cancel', label: 'Cancel delivery of', icon: 'i-hugeicons-cancel-circle', class: 'text-red-500', when: { key: 'cancellable', equals: true } },
72
- { action: 'edit', label: 'Edit', icon: 'i-hugeicons-edit-02', when: { key: 'editable', equals: true } },
73
- { action: 'delete', label: 'Delete', icon: 'i-hugeicons-delete-02', class: 'text-red-500', when: { key: 'deletable', equals: true } },
72
+ { action: 'edit', label: 'Edit', when: { key: 'editable', equals: true } },
73
+ { action: 'delete', label: 'Delete', when: { key: 'deletable', equals: true } },
74
74
  ]
75
75
 
76
76
  const rows = derived(() => records().map(record => ({
@@ -212,7 +212,7 @@ onMount(() => {
212
212
  <article class="p-4 bg-white dark:bg-neutral-800 border border-gray-200 rounded-lg dark:border-neutral-700"><p class="text-gray-500 text-xs dark:text-neutral-400">Campaigns</p><p class="mt-2 font-semibold text-2xl text-gray-900 dark:text-white">{{ summary().campaigns.toLocaleString() }}</p><p class="mt-1 text-gray-500 text-xs dark:text-neutral-500">Linked campaign records</p></article>
213
213
  </section>
214
214
 
215
- <section class="space-y-3">
215
+ <section class="flex flex-col gap-3">
216
216
  <div class="grid gap-3 grid-cols-1 sm:grid-cols-2 xl:grid-cols-4">
217
217
  <label class="xl:col-span-1"><span class="sr-only">Search email lists</span><input x-model="search" type="search" placeholder="Search email lists" class="px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-800 border border-gray-300 rounded-md dark:border-neutral-700" /></label>
218
218
  <label><span class="sr-only">Filter status</span><select x-model="statusFilter" class="px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-800 border border-gray-300 rounded-md dark:border-neutral-700"><option value="all">All statuses</option><option value="active">Active</option><option value="inactive">Inactive</option><option value="archived">Archived</option></select></label>
@@ -32,8 +32,8 @@ const COLUMNS = [
32
32
  ]
33
33
 
34
34
  const ROW_ACTIONS = [
35
- { action: 'edit', label: 'Edit', icon: 'i-hugeicons-edit-01' },
36
- { action: 'delete', label: 'Delete', icon: 'i-hugeicons-delete-02', class: 'text-red-500' },
35
+ { action: 'edit', label: 'Edit' },
36
+ { action: 'delete', label: 'Delete' },
37
37
  ]
38
38
 
39
39
  const rows = derived(() => records().map(record => ({
@@ -99,9 +99,7 @@ function submit(): void {
99
99
  <span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Owner</span>
100
100
  <select x-model="userId" 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">
101
101
  <option value="">Unassigned</option>
102
- <template :for="user in users()" :key="user.id">
103
- <option :value="user.id">{{ user.name }}{{ user.email ? ' - ' + user.email : '' }}</option>
104
- </template>
102
+ <option :for="user in users()" :key="user.id" :value="user.id">{{ user.name }}{{ user.email ? ' - ' + user.email : '' }}</option>
105
103
  </select>
106
104
  </label>
107
105
  </div>
@@ -195,12 +195,12 @@ onMount(() => {
195
195
  <article class="p-4 bg-white dark:bg-neutral-800 border border-gray-200 rounded-lg dark:border-neutral-700"><p class="text-gray-500 text-xs dark:text-neutral-400">Engagement</p><p class="mt-2 font-semibold text-2xl text-gray-900 dark:text-white">{{ summary().engagement.toLocaleString() }}</p><p class="mt-1 text-gray-500 text-xs dark:text-neutral-500">Likes, shares, and comments</p></article>
196
196
  </section>
197
197
 
198
- <section class="space-y-3">
198
+ <section class="flex flex-col gap-3">
199
199
  <div class="grid gap-3 grid-cols-1 sm:grid-cols-2 xl:grid-cols-5">
200
200
  <label><span class="sr-only">Search social posts</span><input x-model="search" type="search" placeholder="Search social posts" class="px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-800 border border-gray-300 rounded-md dark:border-neutral-700" /></label>
201
201
  <label><span class="sr-only">Filter social status</span><select x-model="statusFilter" class="px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-800 border border-gray-300 rounded-md dark:border-neutral-700"><option value="all">All statuses</option><option value="draft">Draft</option><option value="scheduled">Scheduled</option><option value="published">Published</option><option value="failed">Failed</option></select></label>
202
202
  <label><span class="sr-only">Filter platform</span><select x-model="platformFilter" class="px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-800 border border-gray-300 rounded-md dark:border-neutral-700"><option value="all">All platforms</option><option value="twitter">Twitter</option><option value="facebook">Facebook</option><option value="instagram">Instagram</option><option value="linkedin">LinkedIn</option><option value="tiktok">TikTok</option><option value="youtube">YouTube</option></select></label>
203
- <label><span class="sr-only">Filter owner</span><select x-model="authorFilter" class="px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-800 border border-gray-300 rounded-md dark:border-neutral-700"><option value="all">All owners</option><option value="">Unassigned</option><template :for="user in users()" :key="user.id"><option :value="user.id">{{ user.name }}</option></template></select></label>
203
+ <label><span class="sr-only">Filter owner</span><select x-model="authorFilter" class="px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-800 border border-gray-300 rounded-md dark:border-neutral-700"><option value="all">All owners</option><option value="">Unassigned</option><option :for="user in users()" :key="user.id" :value="user.id">{{ user.name }}</option></select></label>
204
204
  <label><span class="sr-only">Sort social posts</span><select x-model="sort" class="px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-800 border border-gray-300 rounded-md dark:border-neutral-700"><option value="newest">Newest</option><option value="scheduled">Latest schedule</option><option value="reach">Most reach</option><option value="engagement">Most engagement</option></select></label>
205
205
  </div>
206
206
  <SocialPostsTable :sort-reset-key="sort()" :page-reset-key="viewKey()" :records="filteredRecords()" :loading="loading()" @edit="openEdit" @delete="openDelete" />
@@ -47,8 +47,8 @@ const COLUMNS = [
47
47
  ]
48
48
 
49
49
  const ROW_ACTIONS = [
50
- { action: 'edit', label: 'Edit social post', icon: 'i-hugeicons-edit-01' },
51
- { action: 'delete', label: 'Delete social post', icon: 'i-hugeicons-delete-02', class: 'text-red-500' },
50
+ { action: 'edit', label: 'Edit social post' },
51
+ { action: 'delete', label: 'Delete social post' },
52
52
  ]
53
53
 
54
54
  const rows = derived(() => records().map(record => ({
@@ -3,10 +3,19 @@ const record = useReactiveProp('record', {} as Record<string, unknown>)
3
3
  const modelName = useReactiveProp('modelName', 'Record')
4
4
  const canUpdate = useReactiveProp('canUpdate', false)
5
5
  const canDestroy = useReactiveProp('canDestroy', false)
6
- const emit = defineEmits(['edit', 'delete'])
6
+ const emit = defineEmits(['view', 'edit', 'delete'])
7
7
  </script>
8
8
 
9
9
  <div class="flex gap-1 items-center justify-end">
10
+ <Button
11
+ variant="ghost"
12
+ size="sm"
13
+ iconOnly
14
+ :ariaLabel="'View ' + modelName() + ' ' + record().id"
15
+ @click="emit('view', record())"
16
+ >
17
+ <span class="h-4 w-4 text-neutral-500 dark:text-neutral-400 i-hugeicons-view"></span>
18
+ </Button>
10
19
  <Button
11
20
  :if="canUpdate()"
12
21
  variant="ghost"
@@ -15,7 +24,7 @@ const emit = defineEmits(['edit', 'delete'])
15
24
  :ariaLabel="'Edit ' + modelName() + ' ' + record().id"
16
25
  @click="emit('edit', record())"
17
26
  >
18
- <span class="h-4 w-4 i-hugeicons-edit-02"></span>
27
+ <span class="h-4 w-4 text-blue-500 i-hugeicons-pencil-edit-02"></span>
19
28
  </Button>
20
29
  <Button
21
30
  :if="canDestroy()"
@@ -0,0 +1,193 @@
1
+ <script client>
2
+ // The page that creates a record (`/models/{slug}/create`), where the Create
3
+ // button on a model's list leads. Laid out like the record's view and edit
4
+ // pages: a breadcrumb back to the list, "Create Team", and the fields the
5
+ // model's API accepts for a new record. A refusal stays on the page, with
6
+ // each field's message under its field. A created record opens on its own
7
+ // page.
8
+ import { useNavigation } from '@stacksjs/defaults/views/dashboard/composables/useNavigation'
9
+ import type { ModelCreateField, ModelCreateForm } from '../../../../functions/dashboard-model-record'
10
+ import { createModelRecord, fetchModelCreateForm, modelRecordBackHref, modelRecordHref, modelRecordListLabel } from '../../../../functions/dashboard-model-record'
11
+ import { pushToast } from '../../../../functions/toasts'
12
+
13
+ const navigation = useNavigation()
14
+ const form = state<ModelCreateForm | null>(null)
15
+ const values = state<Record<string, unknown>>({})
16
+ const loading = state(true)
17
+ const loadError = state('')
18
+ const creating = state(false)
19
+ const createError = state('')
20
+ const createErrors = state<Record<string, string[]>>({})
21
+
22
+ // `/models/{slug}/create`
23
+ function slug(): string {
24
+ return navigation.urlSegment(-2)
25
+ }
26
+
27
+ const from = navigation.urlQuery('from')
28
+ const listHref = derived(() => modelRecordBackHref(slug(), from))
29
+ const listLabel = derived(() => modelRecordListLabel(form(), listHref()))
30
+ const modelName = derived(() => form()?.modelName || 'Record')
31
+ const fields = derived(() => form()?.fields ?? [])
32
+ const canCreate = derived(() => Boolean(form()?.canCreate) && fields().length > 0)
33
+
34
+ function setValue(field: string, value: unknown): void {
35
+ values.set({ ...values(), [field]: value })
36
+ }
37
+
38
+ function fieldValue(field: string): string {
39
+ const value = values()[field]
40
+ return value === null || value === undefined ? '' : String(value)
41
+ }
42
+
43
+ function fieldError(field: string): string {
44
+ return createErrors()[field]?.[0] || ''
45
+ }
46
+
47
+ function inputType(field: ModelCreateField): 'date' | 'datetime-local' | 'email' | 'number' | 'text' {
48
+ if (field.type === 'datetime')
49
+ return 'datetime-local'
50
+ if (field.type === 'date' || field.type === 'email' || field.type === 'number')
51
+ return field.type
52
+ return 'text'
53
+ }
54
+
55
+ async function loadForm(): Promise<void> {
56
+ loading.set(true)
57
+ loadError.set('')
58
+ try {
59
+ const loaded = await fetchModelCreateForm(slug())
60
+ form.set(loaded)
61
+ values.set(Object.fromEntries(loaded.fields.map(field => [field.name, field.defaultValue])))
62
+ }
63
+ catch (error) {
64
+ form.set(null)
65
+ loadError.set(error instanceof Error ? error.message : 'This form could not be loaded.')
66
+ }
67
+ finally {
68
+ loading.set(false)
69
+ }
70
+ }
71
+
72
+ async function create(): Promise<void> {
73
+ if (creating())
74
+ return
75
+ creating.set(true)
76
+ createError.set('')
77
+ createErrors.set({})
78
+ try {
79
+ const result = await createModelRecord(slug(), { ...values() })
80
+ if (!result.ok) {
81
+ createError.set(result.error)
82
+ createErrors.set(result.errors)
83
+ return
84
+ }
85
+ pushToast('success', `${modelName()} created`, { detail: result.id ? `Record ${result.id}` : undefined })
86
+ navigate(result.id === null ? listHref() : modelRecordHref(slug(), result.id, listHref() === from ? from : undefined))
87
+ }
88
+ finally {
89
+ creating.set(false)
90
+ }
91
+ }
92
+
93
+ function cancel(): void {
94
+ if (!creating())
95
+ navigate(listHref())
96
+ }
97
+
98
+ onMount(() => {
99
+ void loadForm()
100
+ })
101
+ </script>
102
+
103
+ <div class="flex flex-col gap-6">
104
+ <header class="min-w-0">
105
+ <nav aria-label="Breadcrumb" class="flex gap-2 items-center mb-2 text-neutral-500 text-sm dark:text-neutral-400">
106
+ <StxLink :to="listHref()" class="font-medium hover:text-blue-600 dark:hover:text-blue-400">{{ listLabel() }}</StxLink>
107
+ <span aria-hidden="true" class="h-4 w-4 i-hugeicons-arrow-right-01"></span>
108
+ <span aria-current="page">Create</span>
109
+ </nav>
110
+ <h1 class="font-bold text-3xl text-neutral-900 tracking-tight truncate dark:text-white">Create {{ modelName() }}</h1>
111
+ </header>
112
+
113
+ <div :if="loading()" class="flex items-center justify-center py-20 text-neutral-500 text-sm dark:text-neutral-400">
114
+ <span aria-hidden="true" class="mr-2 h-5 w-5 animate-spin i-hugeicons-loading-03"></span>
115
+ Loading form
116
+ </div>
117
+
118
+ <div :if="!loading() && loadError()" role="alert" class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between px-4 py-3 text-red-700 text-sm dark:text-red-300 bg-red-50 dark:bg-red-950/40 border border-red-200 rounded-lg dark:border-red-900">
119
+ <span>{{ loadError() }}</span>
120
+ <Button variant="secondary" size="sm" @click="loadForm">Try again</Button>
121
+ </div>
122
+
123
+ <EmptyState
124
+ :if="!loading() && form() && !canCreate()"
125
+ icon="i-hugeicons-square-lock-02"
126
+ :title="modelName() + ' records cannot be created here'"
127
+ description="This model does not accept new records through the dashboard."
128
+ />
129
+
130
+ <form :if="!loading() && canCreate()" id="model-create-form" class="flex flex-col gap-6" @submit.prevent="create">
131
+ <div :if="createError()" role="alert" class="px-4 py-3 text-red-700 text-sm dark:text-red-300 bg-red-50 dark:bg-red-950/40 border border-red-200 rounded-lg dark:border-red-900">
132
+ {{ createError() }}
133
+ </div>
134
+
135
+ <div class="max-w-3xl">
136
+ <Card padding="none">
137
+ <div class="px-6 py-4 border-b border-neutral-200 dark:border-neutral-700">
138
+ <h2 class="font-semibold text-base text-neutral-900 dark:text-white">{{ modelName() }} Details</h2>
139
+ <p class="mt-1 text-neutral-500 text-xs dark:text-neutral-400">The fields a new {{ modelName().toLowerCase() }} can be given. Anything else is set by the application.</p>
140
+ </div>
141
+ <div class="flex flex-col gap-5 p-6">
142
+ <div :for="field in fields()" class="contents">
143
+ <label :if="field.type === 'boolean'" class="flex gap-3 items-start p-3 border border-neutral-200 rounded-lg dark:border-neutral-700">
144
+ <input
145
+ :name="field.name"
146
+ type="checkbox"
147
+ :checked="Boolean(values()[field.name])"
148
+ :disabled="creating()"
149
+ class="mt-0.5 h-4 w-4 text-blue-600 border-neutral-300 rounded"
150
+ @change="setValue(field.name, $event.target.checked)"
151
+ />
152
+ <span>
153
+ <span class="block font-medium text-neutral-900 text-sm dark:text-white">{{ field.label }}</span>
154
+ <span :if="fieldError(field.name)" class="block mt-0.5 text-red-600 text-xs dark:text-red-400">{{ fieldError(field.name) }}</span>
155
+ </span>
156
+ </label>
157
+
158
+ <Select
159
+ :if="field.type === 'enum'"
160
+ :name="field.name"
161
+ :value="fieldValue(field.name)"
162
+ :options="field.options"
163
+ :label="field.label"
164
+ :ariaLabel="field.label"
165
+ :required="field.required"
166
+ :disabled="creating()"
167
+ :error="fieldError(field.name)"
168
+ @update:value="setValue(field.name, $event)"
169
+ />
170
+
171
+ <Input
172
+ :if="field.type !== 'boolean' && field.type !== 'enum'"
173
+ :name="field.name"
174
+ :value="fieldValue(field.name)"
175
+ :type="inputType(field)"
176
+ :label="field.label"
177
+ :ariaLabel="field.label"
178
+ :required="field.required"
179
+ :disabled="creating()"
180
+ :error="fieldError(field.name)"
181
+ @update:value="setValue(field.name, $event)"
182
+ />
183
+ </div>
184
+ </div>
185
+ </Card>
186
+ </div>
187
+
188
+ <div class="flex gap-3 items-center">
189
+ <Button type="submit" variant="primary" :loading="creating()">{{ 'Create ' + modelName() }}</Button>
190
+ <Button variant="secondary" :disabled="creating()" @click="cancel">Cancel</Button>
191
+ </div>
192
+ </form>
193
+ </div>