@stacksjs/defaults 0.75.611 → 0.75.613

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 (116) hide show
  1. package/ai/skills/stacks-actions/SKILL.md +208 -0
  2. package/ai/skills/stacks-api/SKILL.md +1 -1
  3. package/ai/skills/stacks-buddy/SKILL.md +1 -1
  4. package/ai/skills/stacks-dashboard/SKILL.md +79 -0
  5. package/ai/skills/stacks-middleware/SKILL.md +4 -1
  6. package/ai/skills/stacks-native/CATALOG.md +12 -12
  7. package/ai/skills/stacks-validation/SKILL.md +7 -0
  8. package/app/Actions/Storefront/AddToCartAction.ts +12 -15
  9. package/app/Actions/Storefront/CheckoutContactAction.ts +18 -10
  10. package/app/Actions/Storefront/CheckoutShippingAction.ts +20 -10
  11. package/app/Actions/Storefront/PlaceOrderAction.ts +9 -12
  12. package/app/Actions/Storefront/UpdateCartItemAction.ts +11 -9
  13. package/app/Middleware/Abilities.ts +4 -3
  14. package/app/Middleware/Csrf.ts +10 -1
  15. package/app/Middleware/Throttle.ts +4 -4
  16. package/ide/vscode/package.json +1 -1
  17. package/package.json +5 -5
  18. package/resources/components/Dashboard/Analytics/AnalyticsPageHeader.stx +3 -13
  19. package/resources/components/Dashboard/App/RequestsOverview.stx +3 -20
  20. package/resources/components/Dashboard/App/SourceInventory.stx +1 -5
  21. package/resources/components/Dashboard/Auth/AccessTokenCreateDialog.stx +11 -28
  22. package/resources/components/Dashboard/Commerce/CommerceCategoriesDashboard.stx +4 -8
  23. package/resources/components/Dashboard/Commerce/CommerceCategoryDialog.stx +9 -9
  24. package/resources/components/Dashboard/Commerce/CommerceCouponDialog.stx +14 -14
  25. package/resources/components/Dashboard/Commerce/CommerceCouponsDashboard.stx +5 -9
  26. package/resources/components/Dashboard/Commerce/CommerceCustomerDialog.stx +7 -7
  27. package/resources/components/Dashboard/Commerce/CommerceCustomersDashboard.stx +3 -7
  28. package/resources/components/Dashboard/Commerce/CommerceGiftCardDialog.stx +15 -15
  29. package/resources/components/Dashboard/Commerce/CommerceGiftCardsDashboard.stx +5 -9
  30. package/resources/components/Dashboard/Commerce/CommerceManufacturerDialog.stx +12 -15
  31. package/resources/components/Dashboard/Commerce/CommerceManufacturersDashboard.stx +4 -28
  32. package/resources/components/Dashboard/Commerce/CommerceOrderDialog.stx +15 -15
  33. package/resources/components/Dashboard/Commerce/CommerceOrdersDashboard.stx +4 -8
  34. package/resources/components/Dashboard/Commerce/CommerceOverviewDashboard.stx +3 -11
  35. package/resources/components/Dashboard/Commerce/CommercePaymentsDashboard.stx +8 -9
  36. package/resources/components/Dashboard/Commerce/CommercePosCatalog.stx +3 -20
  37. package/resources/components/Dashboard/Commerce/CommercePosCheckoutDialog.stx +4 -4
  38. package/resources/components/Dashboard/Commerce/CommerceProductDialog.stx +14 -14
  39. package/resources/components/Dashboard/Commerce/CommerceProductsDashboard.stx +4 -8
  40. package/resources/components/Dashboard/Commerce/CommerceReviewEditDialog.stx +14 -24
  41. package/resources/components/Dashboard/Commerce/CommerceReviewsDashboard.stx +5 -43
  42. package/resources/components/Dashboard/Commerce/CommerceTaxDialog.stx +22 -38
  43. package/resources/components/Dashboard/Commerce/CommerceTaxesDashboard.stx +5 -33
  44. package/resources/components/Dashboard/Commerce/CommerceUnitDialog.stx +16 -30
  45. package/resources/components/Dashboard/Commerce/CommerceUnitsDashboard.stx +4 -28
  46. package/resources/components/Dashboard/Commerce/CommerceVariantDialog.stx +15 -9
  47. package/resources/components/Dashboard/Commerce/CommerceVariantsDashboard.stx +8 -9
  48. package/resources/components/Dashboard/Commerce/Delivery/CourierDialog.stx +14 -12
  49. package/resources/components/Dashboard/Commerce/Delivery/DeliveryRouteDialog.stx +9 -11
  50. package/resources/components/Dashboard/Commerce/Delivery/DigitalDeliveryDialog.stx +15 -9
  51. package/resources/components/Dashboard/Commerce/Delivery/LicenseKeyDialog.stx +11 -7
  52. package/resources/components/Dashboard/Commerce/Delivery/ShippingMethodDialog.stx +14 -8
  53. package/resources/components/Dashboard/Commerce/Delivery/ShippingRateDialog.stx +11 -17
  54. package/resources/components/Dashboard/Commerce/Delivery/ShippingZoneDialog.stx +18 -12
  55. package/resources/components/Dashboard/Commerce/PaymentRefundDialog.stx +1 -1
  56. package/resources/components/Dashboard/Commerce/PrintDeviceDialog.stx +5 -5
  57. package/resources/components/Dashboard/Commerce/PrintDevicesDashboard.stx +4 -8
  58. package/resources/components/Dashboard/Commerce/PrintLogsDashboard.stx +5 -9
  59. package/resources/components/Dashboard/Commerce/ProductWaitlistDashboard.stx +2 -10
  60. package/resources/components/Dashboard/Commerce/ProductWaitlistEntryDialog.stx +14 -67
  61. package/resources/components/Dashboard/Commerce/RestaurantWaitlistDashboard.stx +3 -18
  62. package/resources/components/Dashboard/Commerce/RestaurantWaitlistEntryDialog.stx +23 -69
  63. package/resources/components/Dashboard/Content/AuthorEditorDialog.stx +4 -16
  64. package/resources/components/Dashboard/Content/BlogDashboard.stx +2 -19
  65. package/resources/components/Dashboard/Content/BlogPostEditorDialog.stx +31 -51
  66. package/resources/components/Dashboard/Content/CommentsDashboard.stx +1 -1
  67. package/resources/components/Dashboard/Content/ContentDashboard.stx +1 -11
  68. package/resources/components/Dashboard/Content/CreateFolderDialog.stx +1 -4
  69. package/resources/components/Dashboard/Content/FileManagerDashboard.stx +2 -2
  70. package/resources/components/Dashboard/Content/PageEditorDialog.stx +8 -17
  71. package/resources/components/Dashboard/Content/PostEditorDialog.stx +35 -45
  72. package/resources/components/Dashboard/Content/PostsDashboard.stx +1 -13
  73. package/resources/components/Dashboard/Content/SeoDashboard.stx +2 -20
  74. package/resources/components/Dashboard/Content/SeoEditorDialog.stx +4 -38
  75. package/resources/components/Dashboard/Content/TaxonomyEditorDialog.stx +8 -15
  76. package/resources/components/Dashboard/Data/ActivityLog.stx +1 -5
  77. package/resources/components/Dashboard/Deployments/DeploymentList.stx +2 -11
  78. package/resources/components/Dashboard/Email/InboxMessageList.stx +1 -5
  79. package/resources/components/Dashboard/Infrastructure/DnsDashboard.stx +2 -16
  80. package/resources/components/Dashboard/Infrastructure/LogsDashboard.stx +6 -10
  81. package/resources/components/Dashboard/Infrastructure/MailboxesDashboard.stx +1 -5
  82. package/resources/components/Dashboard/Infrastructure/ServersDashboard.stx +1 -5
  83. package/resources/components/Dashboard/Jobs/JobHistory.stx +3 -12
  84. package/resources/components/Dashboard/Kanban/KanbanCardDialog.stx +57 -51
  85. package/resources/components/Dashboard/Library/ComponentsDashboard.stx +4 -14
  86. package/resources/components/Dashboard/Library/DependenciesDashboard.stx +2 -15
  87. package/resources/components/Dashboard/Library/PackagesDashboard.stx +1 -8
  88. package/resources/components/Dashboard/Library/SourceScaffoldDialog.stx +1 -12
  89. package/resources/components/Dashboard/Management/PermissionsDashboard.stx +3 -3
  90. package/resources/components/Dashboard/Marketing/AbandonedCartsDashboard.stx +4 -4
  91. package/resources/components/Dashboard/Marketing/CampaignDeliveryDialog.stx +3 -5
  92. package/resources/components/Dashboard/Marketing/CampaignDialog.stx +59 -93
  93. package/resources/components/Dashboard/Marketing/CampaignsDashboard.stx +5 -5
  94. package/resources/components/Dashboard/Marketing/MarketingListDialog.stx +12 -26
  95. package/resources/components/Dashboard/Marketing/MarketingListsDashboard.stx +4 -4
  96. package/resources/components/Dashboard/Marketing/RecoveryCampaignDialog.stx +12 -43
  97. package/resources/components/Dashboard/Marketing/SocialPostDialog.stx +7 -41
  98. package/resources/components/Dashboard/Marketing/SocialPostsDashboard.stx +5 -5
  99. package/resources/components/Dashboard/Models/ModelRecordsDashboard.stx +7 -23
  100. package/resources/components/Dashboard/Models/ModelsOverview.stx +2 -12
  101. package/resources/components/Dashboard/Notifications/NotificationDeliveries.stx +4 -27
  102. package/resources/components/Dashboard/Notifications/NotificationDeliveryHistory.stx +4 -36
  103. package/resources/components/Dashboard/Operations/RecoveryDestinationDialog.stx +18 -47
  104. package/resources/components/Dashboard/Operations/RecoveryPolicyDialog.stx +24 -78
  105. package/resources/components/Dashboard/Operations/RecoveryRestoreDialog.stx +8 -19
  106. package/resources/components/Dashboard/Queries/QueryDashboard.stx +3 -21
  107. package/resources/components/Dashboard/Releases/ReleaseDashboard.stx +2 -9
  108. package/resources/components/Dashboard/Settings/SettingsDashboard.stx +1 -11
  109. package/resources/components/Dashboard/UI/Input.stx +50 -1
  110. package/resources/components/Dashboard/UI/SearchFilter.stx +27 -17
  111. package/resources/components/Dashboard/UI/Select.stx +4 -1
  112. package/resources/components/Dashboard/UI/Textarea.stx +16 -1
  113. package/resources/views/cart.stx +14 -0
  114. package/resources/views/checkout/contact.stx +15 -1
  115. package/resources/views/checkout/payment.stx +7 -0
  116. package/resources/views/checkout/shipping.stx +39 -5
@@ -1,6 +1,7 @@
1
1
  import { Action } from '@stacksjs/actions/runtime'
2
2
  import { db } from '@stacksjs/database/runtime'
3
- import { response } from '@stacksjs/router'
3
+ import { refuse } from '@stacksjs/router'
4
+ import { schema } from '@stacksjs/validation/runtime'
4
5
  import { readCartCookie } from '../../Storefront/CartCookie'
5
6
 
6
7
  const CART_COOKIE = 'stacks_cart'
@@ -13,6 +14,19 @@ export default new Action({
13
14
  name: 'CheckoutShippingAction',
14
15
  description: 'Save shipping address on the active cart.',
15
16
  method: 'POST',
17
+ // A browser form goes on to the next step; a script gets `next` in the body.
18
+ next: '/checkout/payment',
19
+
20
+ // Declared, so a missing field is answered the way the caller asked: the
21
+ // checkout page gets the shopper back with the message under the field and
22
+ // what they typed kept (stacksjs/stacks#3311). A field of spaces is missing.
23
+ validations: {
24
+ shipping_name: { rule: schema.string().matches(/\S/).required(), message: 'Enter the name to ship to.' },
25
+ shipping_address: { rule: schema.string().matches(/\S/).required(), message: 'Enter the street address.' },
26
+ shipping_city: { rule: schema.string().matches(/\S/).required(), message: 'Enter the city.' },
27
+ shipping_state: { rule: schema.string().matches(/\S/).required(), message: 'Enter the state.' },
28
+ shipping_zip: { rule: schema.string().matches(/\S/).required(), message: 'Enter the ZIP or postal code.' },
29
+ },
16
30
 
17
31
  async handle(request: any) {
18
32
  const name = String(request.get('shipping_name') ?? '').trim()
@@ -21,12 +35,13 @@ export default new Action({
21
35
  const state = String(request.get('shipping_state') ?? '').trim()
22
36
  const zip = String(request.get('shipping_zip') ?? '').trim()
23
37
 
38
+ // For a caller that runs the action without the router in front of it.
24
39
  if (!name || !address || !city || !state || !zip)
25
- return response.json({ error: 'All shipping fields are required.' }, { status: 422 })
40
+ return refuse('All shipping fields are required.')
26
41
 
27
42
  const token = readCartCookie(request, CART_COOKIE)
28
43
  if (!token)
29
- return response.json({ error: 'Your cart is empty.' }, { status: 400 })
44
+ return refuse('Your cart is empty.', { status: 400 })
30
45
 
31
46
  const cart = await (db as any)
32
47
  .selectFrom('carts')
@@ -36,7 +51,7 @@ export default new Action({
36
51
  .executeTakeFirst()
37
52
 
38
53
  if (!cart)
39
- return response.json({ error: 'Your cart is empty.' }, { status: 400 })
54
+ return refuse('Your cart is empty.', { status: 400 })
40
55
 
41
56
  await (db as any)
42
57
  .updateTable('carts')
@@ -51,11 +66,6 @@ export default new Action({
51
66
  .where('id', '=', cart.id)
52
67
  .execute()
53
68
 
54
- const wantsHtml = (request.headers?.get?.('accept') || '').includes('text/html')
55
- const xhr = request.headers?.get?.('x-requested-with') === 'XMLHttpRequest'
56
- if (wantsHtml && !xhr)
57
- return response.redirect('/checkout/payment')
58
-
59
- return response.json({ ok: true, next: '/checkout/payment' })
69
+ return { ok: true, next: '/checkout/payment' }
60
70
  },
61
71
  })
@@ -3,7 +3,7 @@ import { Action } from '@stacksjs/actions/runtime'
3
3
  import { customers } from '@stacksjs/commerce'
4
4
  import { config } from '@stacksjs/config'
5
5
  import { db } from '@stacksjs/database/runtime'
6
- import { response } from '@stacksjs/router'
6
+ import { refuse } from '@stacksjs/router'
7
7
  import { sendOrderConfirmation } from '../../Mail/OrderConfirmation'
8
8
  import { readCartCookie } from '../../Storefront/CartCookie'
9
9
  import { storefrontCurrency } from '../../Storefront/StorefrontMoney'
@@ -28,11 +28,13 @@ export default new Action({
28
28
  name: 'PlaceOrderAction',
29
29
  description: 'Convert the active cart into an Order + OrderItems.',
30
30
  method: 'POST',
31
+ // A browser form goes to the order it placed; a script gets its id and totals.
32
+ next: (result: { order_id: number }) => `/orders/${result.order_id}`,
31
33
 
32
34
  async handle(request: any) {
33
35
  const token = readCartCookie(request, CART_COOKIE)
34
36
  if (!token)
35
- return response.json({ error: 'Your cart is empty.' }, { status: 400 })
37
+ return refuse('Your cart is empty.', { status: 400 })
36
38
 
37
39
  const cart = await (db as any)
38
40
  .selectFrom('carts')
@@ -42,7 +44,7 @@ export default new Action({
42
44
  .executeTakeFirst()
43
45
 
44
46
  if (!cart)
45
- return response.json({ error: 'Your cart is empty.' }, { status: 400 })
47
+ return refuse('Your cart is empty.', { status: 400 })
46
48
 
47
49
  const items = await (db as any)
48
50
  .selectFrom('cart_items')
@@ -51,10 +53,10 @@ export default new Action({
51
53
  .execute()
52
54
 
53
55
  if (items.length === 0)
54
- return response.json({ error: 'Your cart is empty.' }, { status: 400 })
56
+ return refuse('Your cart is empty.', { status: 400 })
55
57
 
56
58
  if (!cart.email || !cart.shipping_name || !cart.shipping_address)
57
- return response.json({ error: 'Checkout details are incomplete.' }, { status: 422 })
59
+ return refuse('Checkout details are incomplete. Go back and fill in your email and shipping address.')
58
60
 
59
61
  // One customer per email — repeat shoppers reuse the same row so
60
62
  // the dashboard's customer total isn't inflated by checkouts.
@@ -179,17 +181,12 @@ export default new Action({
179
181
  console.error(`[PlaceOrderAction] order receipt email failed for order #${order.id}:`, message)
180
182
  })
181
183
 
182
- const wantsHtml = (request.headers?.get?.('accept') || '').includes('text/html')
183
- const xhr = request.headers?.get?.('x-requested-with') === 'XMLHttpRequest'
184
- if (wantsHtml && !xhr)
185
- return response.redirect(`/orders/${order.id}`)
186
-
187
- return response.json({
184
+ return {
188
185
  ok: true,
189
186
  order_id: order.id,
190
187
  total,
191
188
  subtotal,
192
189
  shipping,
193
- })
190
+ }
194
191
  },
195
192
  })
@@ -1,6 +1,6 @@
1
1
  import { Action } from '@stacksjs/actions/runtime'
2
2
  import { db } from '@stacksjs/database/runtime'
3
- import { response } from '@stacksjs/router'
3
+ import { refuse, response } from '@stacksjs/router'
4
4
  import { readCartCookie } from '../../Storefront/CartCookie'
5
5
 
6
6
  const CART_COOKIE = 'stacks_cart'
@@ -9,11 +9,18 @@ const CART_COOKIE = 'stacks_cart'
9
9
  * Change the quantity of a cart line, or remove it (quantity=0).
10
10
  * Scoped by the caller's cart cookie so one shopper can't poke at
11
11
  * another's cart by guessing item ids.
12
+ *
13
+ * The cart page posts plain forms here. The router sends that browser back
14
+ * to the cart with the notice below, and a `fetch()` caller gets the totals
15
+ * (stacksjs/stacks#3312).
12
16
  */
13
17
  export default new Action({
14
18
  name: 'UpdateCartItemAction',
15
19
  description: 'Update or remove a cart item by id, scoped to caller cookie.',
16
20
  method: 'POST',
21
+ // A changed quantity shows on the page itself. A line that disappears
22
+ // needs saying.
23
+ notice: (_result: unknown, request: any) => Number(request.get('quantity') ?? 1) === 0 ? 'Removed from your cart.' : '',
17
24
 
18
25
  async handle(request: any) {
19
26
  const itemId = Number(request.get('item_id') ?? 0)
@@ -23,7 +30,7 @@ export default new Action({
23
30
  // an attacker can't probe for the existence of arbitrary carts.
24
31
  const token = readCartCookie(request, CART_COOKIE)
25
32
  if (!token)
26
- return response.json({ error: 'No active cart' }, { status: 400 })
33
+ return refuse('Your cart is empty.', { status: 400 })
27
34
 
28
35
  const cart = await (db as any)
29
36
  .selectFrom('carts')
@@ -32,7 +39,7 @@ export default new Action({
32
39
  .executeTakeFirst()
33
40
 
34
41
  if (!cart)
35
- return response.json({ error: 'Cart not found' }, { status: 404 })
42
+ return refuse('Your cart is empty.', { status: 404 })
36
43
 
37
44
  const item = await (db as any)
38
45
  .selectFrom('cart_items')
@@ -42,7 +49,7 @@ export default new Action({
42
49
  .executeTakeFirst()
43
50
 
44
51
  if (!item)
45
- return response.json({ error: 'Item not in your cart' }, { status: 404 })
52
+ return refuse('That item is no longer in your cart.', { status: 404 })
46
53
 
47
54
  if (quantity === 0) {
48
55
  await (db as any).deleteFrom('cart_items').where('id', '=', item.id).execute()
@@ -73,11 +80,6 @@ export default new Action({
73
80
  .where('id', '=', cart.id)
74
81
  .execute()
75
82
 
76
- const wantsHtml = (request.headers?.get?.('accept') || '').includes('text/html')
77
- const xhr = request.headers?.get?.('x-requested-with') === 'XMLHttpRequest'
78
- if (wantsHtml && !xhr)
79
- return response.redirect('/cart')
80
-
81
83
  return response.json({ ok: true, total_items: totalItems, subtotal })
82
84
  },
83
85
  })
@@ -36,9 +36,10 @@ export default new Middleware({
36
36
  throw new HttpError(401, 'Unauthenticated.')
37
37
  }
38
38
 
39
- // `_currentAccessToken` is declared `unknown` (the token row is
40
- // project-defined), so name the one field this middleware reads.
41
- const tokenAbilities: string[] = (token as { abilities?: string[] }).abilities || []
39
+ // `scopes`, which every token row carries: the Auth middleware stamps a
40
+ // `PersonalAccessToken`, whose `abilities` copy them, and
41
+ // `currentAccessToken()` the plain row, which has no `abilities` at all.
42
+ const tokenAbilities: readonly string[] = Array.isArray(token.scopes) ? token.scopes : []
42
43
 
43
44
  // Wildcard grants all permissions
44
45
  if (tokenAbilities.includes('*')) {
@@ -61,6 +61,9 @@ import { Middleware, parseBearerToken } from '@stacksjs/router/middleware'
61
61
  export const CSRF_COOKIE_NAME = 'X-CSRF-Token'
62
62
  const CSRF_SECURE_TRANSPORT = Symbol.for('@stacksjs/router:csrf-secure-transport')
63
63
  const CSRF_HEADER_NAME = 'x-csrf-token'
64
+ /** `FORM_REFUSAL` in @stacksjs/router, by its registered name: this module does not load the router. */
65
+ const CSRF_FORM_REFUSAL = Symbol.for('stacks.formRefusal')
66
+ const CSRF_FORM_MESSAGE = 'This form was open too long to be sent safely, so nothing was saved. Check it and send it again.'
64
67
  const CSRF_COOKIE_PREFIX = `${CSRF_COOKIE_NAME}=`
65
68
  const LEGACY_CSRF_COOKIE_PREFIX = 'csrf-token='
66
69
  const JOINED_CSRF_COOKIE_PREFIX = `, ${CSRF_COOKIE_PREFIX}`
@@ -381,7 +384,13 @@ function assertValidCsrfRequest(request: Request | EnhancedRequest): void {
381
384
  // mismatch" — it's not in the IANA list but most SPAs already
382
385
  // know how to refresh on 419. We use 403 for the strict-correct
383
386
  // status code instead (419 is non-standard).
384
- throw new HttpError(403, 'CSRF token mismatch')
387
+ const refusal = new HttpError(403, 'CSRF token mismatch')
388
+ // A browser form from this application's own page (a tab left open past
389
+ // the token's life, a second tab that replaced it) goes back to that page
390
+ // with this, and what was typed, instead of the 403 body. A script and a
391
+ // form from anywhere else get the 403 as before (stacksjs/stacks#3311).
392
+ Object.defineProperty(refusal, CSRF_FORM_REFUSAL, { value: { message: CSRF_FORM_MESSAGE, status: 403 } })
393
+ throw refusal
385
394
  }
386
395
 
387
396
  export async function validateCsrfRequest(request: Request | EnhancedRequest): Promise<void> {
@@ -1,3 +1,4 @@
1
+ import type { EnhancedRequest } from '@stacksjs/router'
1
2
  import { clientAddress, createRateLimitMiddleware, Middleware, parseThrottleString, scaledLimit } from '@stacksjs/router'
2
3
 
3
4
  // Cache for rate limiters to avoid creating new instances for each request
@@ -22,12 +23,11 @@ const RATE_LIMIT_HEADERS = ['X-RateLimit-Limit', 'X-RateLimit-Remaining', 'X-Rat
22
23
  * that delivered the request is Cloudflare). A client-written
23
24
  * `X-Forwarded-For` no longer buys a fresh budget.
24
25
  */
25
- function throttleKey(request: { _authenticatedUser?: unknown }): string {
26
- const user = request._authenticatedUser as { id?: unknown } | null | undefined
27
- const id = user?.id
26
+ function throttleKey(request: EnhancedRequest): string {
27
+ const id = request._authenticatedUser?.id
28
28
  if ((typeof id === 'number' && Number.isFinite(id)) || (typeof id === 'string' && id !== ''))
29
29
  return `user:${id}`
30
- return `ip:${clientAddress(request as unknown as Request) ?? 'unknown'}`
30
+ return `ip:${clientAddress(request) ?? 'unknown'}`
31
31
  }
32
32
 
33
33
  /**
@@ -2,7 +2,7 @@
2
2
  "publisher": "Stacks",
3
3
  "name": "vscode-stacks",
4
4
  "displayName": "Stacks",
5
- "version": "0.75.611",
5
+ "version": "0.75.613",
6
6
  "description": "Stacks, built into VS Code: stx templates, pickier linting and formatting, encrypted env files, the dev server preview and every buddy command. No other extensions required.",
7
7
  "license": "MIT",
8
8
  "funding": "https://github.com/sponsors/chrisbbreuer",
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/defaults",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.611",
5
+ "version": "0.75.613",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/stacksjs/stacks.git",
@@ -45,14 +45,14 @@
45
45
  "dependencies": {
46
46
  "@iconify-json/f7": "^1.2.2",
47
47
  "@iconify-json/hugeicons": "^1.2.35",
48
- "@stacksjs/mobile": "0.75.611",
48
+ "@stacksjs/mobile": "0.75.613",
49
49
  "@stacksjs/sanitizer": "^0.2.889",
50
50
  "@stacksjs/stx": "^0.2.889",
51
- "@stacksjs/strings": "0.75.611",
51
+ "@stacksjs/strings": "0.75.613",
52
52
  "@xterm/addon-fit": "^0.11.0",
53
53
  "@xterm/xterm": "^6.0.0",
54
54
  "ts-qr-codes": "^0.1.8",
55
- "@stacksjs/support": "0.75.611",
56
- "@stacksjs/browser": "0.75.611"
55
+ "@stacksjs/support": "0.75.613",
56
+ "@stacksjs/browser": "0.75.613"
57
57
  }
58
58
  }
@@ -11,8 +11,8 @@ effect(() => {
11
11
  selectedRange.set(range())
12
12
  })
13
13
 
14
- function emitRange(event: Event): void {
15
- emit('range-change', (event.target as HTMLSelectElement).value)
14
+ function emitRange(next: string): void {
15
+ emit('range-change', next)
16
16
  }
17
17
  </script>
18
18
 
@@ -24,17 +24,7 @@ function emitRange(event: Event): void {
24
24
 
25
25
  <div class="flex flex-wrap gap-2 items-center">
26
26
  <span class="text-gray-500 text-sm dark:text-neutral-400">{{ dateRange() }}</span>
27
- <select
28
- x-model="selectedRange"
29
- aria-label="Analytics date range"
30
- class="block pl-3 pr-10 py-1.5 text-gray-900 sm:leading-6 sm:text-sm dark:text-white dark:bg-neutral-800 border-0 ring-1 ring-gray-300 ring-inset rounded-md dark:ring-neutral-700 focus:ring-2 focus:ring-blue-600 focus:ring-inset"
31
- @change="emitRange($event)"
32
- >
33
- <option value="day">Last 24 hours</option>
34
- <option value="week">Last 7 days</option>
35
- <option value="month">Last 30 days</option>
36
- <option value="year">Last year</option>
37
- </select>
27
+ <Select v-model:value="selectedRange" ariaLabel="Analytics date range" placeholder="" :options="[{ value: 'day', label: 'Last 24 hours' }, { value: 'week', label: 'Last 7 days' }, { value: 'month', label: 'Last 30 days' }, { value: 'year', label: 'Last year' }]" @change="emitRange" />
38
28
  <Button variant="secondary" :loading="loading()" @click="emit('refresh')">
39
29
  <span :if="!loading()" class="h-4 w-4 i-hugeicons-refresh"></span>
40
30
  Refresh
@@ -209,26 +209,9 @@ onMount(() => {
209
209
  <p class="mt-1 text-neutral-500 text-xs dark:text-neutral-400">Showing up to 100 persisted records. Last-hour rate: {{ stats().requestsPerMinute.toFixed(2) }} per minute.</p>
210
210
  </div>
211
211
  <div class="grid gap-3 grid-cols-1 sm:grid-cols-[minmax(0,1fr)_auto_auto]">
212
- <label class="block relative">
213
- <span class="sr-only">Search requests</span>
214
- <span class="absolute left-3 top-2.5 h-4 w-4 text-neutral-400 i-hugeicons-search-01"></span>
215
- <input x-model="search" type="search" placeholder="Search path, client, status, or error" class="block pl-9 pr-3 py-2 w-full text-neutral-900 text-sm dark:text-white bg-white dark:bg-neutral-950 border border-neutral-300 rounded-lg dark:border-neutral-700 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20">
216
- </label>
217
- <label>
218
- <span class="sr-only">Method</span>
219
- <select x-model="methodFilter" class="px-3 py-2 w-full text-neutral-900 text-sm dark:text-white bg-white dark:bg-neutral-950 border border-neutral-300 rounded-lg dark:border-neutral-700">
220
- <option value="all">All methods</option>
221
- <option :for="method in methods()" :value="method">{{ method }}</option>
222
- </select>
223
- </label>
224
- <label>
225
- <span class="sr-only">Status</span>
226
- <select x-model="statusFilter" class="px-3 py-2 w-full text-neutral-900 text-sm dark:text-white bg-white dark:bg-neutral-950 border border-neutral-300 rounded-lg dark:border-neutral-700">
227
- <option value="all">All statuses</option>
228
- <option value="success">Below 400</option>
229
- <option value="error">400 and above</option>
230
- </select>
231
- </label>
212
+ <SearchFilter v-model:searchValue="search" placeholder="Search path, client, status, or error" ariaLabel="Search requests" />
213
+ <Select v-model:value="methodFilter" ariaLabel="Method" placeholder="" :options="[{ value: 'all', label: 'All methods' }, ...methods().map(method => ({ value: method, label: method }))]" />
214
+ <Select v-model:value="statusFilter" ariaLabel="Status" placeholder="" :options="[{ value: 'all', label: 'All statuses' }, { value: 'success', label: 'Below 400' }, { value: 'error', label: '400 and above' }]" />
232
215
  </div>
233
216
  </div>
234
217
 
@@ -242,11 +242,7 @@ onMount(() => {
242
242
  <h2 class="font-semibold text-neutral-900 dark:text-white">Native source inventory</h2>
243
243
  <p class="mt-1 text-neutral-500 text-xs dark:text-neutral-400">{{ page().note }}</p>
244
244
  </div>
245
- <label class="block relative w-full sm:max-w-xs">
246
- <span class="sr-only">Search {{ page().title.toLowerCase() }}</span>
247
- <span class="absolute left-3 top-2.5 h-4 w-4 text-neutral-400 i-hugeicons-search-01"></span>
248
- <input x-model="search" type="search" :placeholder="'Search ' + page().title.toLowerCase()" class="block pl-9 pr-3 py-2 w-full text-neutral-900 text-sm dark:text-white bg-white dark:bg-neutral-950 border border-neutral-300 rounded-lg dark:border-neutral-700 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20">
249
- </label>
245
+ <SearchFilter v-model:searchValue="search" :placeholder="'Search ' + page().title.toLowerCase()" :ariaLabel="'Search ' + page().title.toLowerCase()" class="w-full sm:max-w-xs" />
250
246
  </div>
251
247
 
252
248
  <Table
@@ -43,8 +43,7 @@ effect(() => {
43
43
  wasOpen = isOpen
44
44
  })
45
45
 
46
- function toggleScope(event: Event, scope: string): void {
47
- const enabled = (event.target as HTMLInputElement).checked
46
+ function toggleScope(scope: string, enabled: boolean): void {
48
47
  selectedScopes.set(enabled
49
48
  ? [...new Set([...selectedScopes(), scope])]
50
49
  : selectedScopes().filter(item => item !== scope))
@@ -97,38 +96,22 @@ async function copyToken(): Promise<void> {
97
96
  <div role="status" class="px-4 py-3 text-amber-800 text-sm dark:text-amber-200 bg-amber-50 dark:bg-amber-950/40 border border-amber-200 rounded-lg dark:border-amber-900">
98
97
  {{ message() }}
99
98
  </div>
100
- <label class="block">
101
- <span class="font-medium text-neutral-700 text-sm dark:text-neutral-300">New token</span>
102
- <textarea readonly rows="4" aria-label="New access token" class="block mt-2 p-3 w-full font-mono text-neutral-900 text-xs dark:text-white bg-neutral-50 dark:bg-neutral-950 border border-neutral-300 rounded-lg dark:border-neutral-700">{{ createdToken() }}</textarea>
103
- </label>
99
+ <div>
100
+ <Textarea :value="createdToken()" label="New token" ariaLabel="New access token" :readonly="true" :rows="4" :monospace="true" />
101
+ </div>
104
102
  </div>
105
103
 
106
- <form :if="!createdToken()" id="access-token-create-form" class="space-y-5" @submit.prevent="submit">
107
- <label class="block">
108
- <span class="font-medium text-neutral-700 text-sm dark:text-neutral-300">Token name</span>
109
- <input x-model="tokenName" name="name" type="text" maxlength="255" required placeholder="CI deployment" class="block mt-2 px-3 py-2 w-full text-neutral-900 text-sm dark:text-white bg-white dark:bg-neutral-950 border border-neutral-300 rounded-lg dark:border-neutral-700 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20">
110
- </label>
111
-
112
- <label class="block">
113
- <span class="font-medium text-neutral-700 text-sm dark:text-neutral-300">Expires after</span>
114
- <select x-model="expiryMinutes" name="expires_in_minutes" class="block mt-2 px-3 py-2 w-full text-neutral-900 text-sm dark:text-white bg-white dark:bg-neutral-950 border border-neutral-300 rounded-lg dark:border-neutral-700 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20">
115
- <option value="60">1 hour</option>
116
- <option value="1440">1 day</option>
117
- <option value="10080">7 days</option>
118
- <option value="43200">30 days</option>
119
- </select>
120
- </label>
104
+ <form :if="!createdToken()" id="access-token-create-form" class="grid gap-5" @submit.prevent="submit">
105
+ <Input v-model:value="tokenName" name="name" label="Token name" :maxLength="255" :required="true" placeholder="CI deployment" />
106
+ <Select v-model:value="expiryMinutes" name="expires_in_minutes" label="Expires after" placeholder="" :options="[{ value: '60', label: '1 hour' }, { value: '1440', label: '1 day' }, { value: '10080', label: '7 days' }, { value: '43200', label: '30 days' }]" />
121
107
 
122
108
  <fieldset>
123
109
  <legend class="font-medium text-neutral-700 text-sm dark:text-neutral-300">Scopes</legend>
124
110
  <div class="grid gap-2 grid-cols-1 sm:grid-cols-2 mt-2">
125
- <label :for="scope in availableScopes" class="flex gap-3 items-start p-3 border border-neutral-200 rounded-lg dark:border-neutral-700">
126
- <input name="scopes" type="checkbox" :value="scope.name" :checked="selectedScopes().includes(scope.name)" class="mt-0.5 h-4 w-4 text-blue-600 rounded" @change="toggleScope($event, scope.name)">
127
- <span>
128
- <span class="block font-medium text-neutral-900 text-sm dark:text-white">{{ scope.name }}</span>
129
- <span class="block mt-0.5 text-neutral-500 text-xs dark:text-neutral-400">{{ scope.description }}</span>
130
- </span>
131
- </label>
111
+ <!-- Several of many: a shared checkbox per scope. The loop is on the card, not the component. -->
112
+ <div :for="scope in availableScopes" class="p-3 border border-neutral-200 rounded-lg dark:border-neutral-700">
113
+ <Checkbox size="sm" :label="scope.name" :description="scope.description" :checked="selectedScopes().includes(scope.name)" @update:checked="toggleScope(scope.name, $event)" />
114
+ </div>
132
115
  </div>
133
116
  </fieldset>
134
117
  </form>
@@ -240,14 +240,10 @@ onMount(() => {
240
240
 
241
241
  <section class="flex flex-col gap-3">
242
242
  <div class="grid gap-3 grid-cols-1 sm:grid-cols-2 xl:grid-cols-5">
243
- <label class="relative sm:col-span-2">
244
- <span class="sr-only">Search product categories</span>
245
- <span class="flex absolute inset-y-0 left-0 items-center pl-3 text-gray-400 pointer-events-none"><span class="h-4 w-4 i-hugeicons-search-01"></span></span>
246
- <input x-model="search" type="search" placeholder="Search names, slugs, or descriptions" class="pl-9 pr-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" />
247
- </label>
248
- <label><span class="sr-only">Category availability</span><select x-model="activeFilter" 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">Any availability</option><option value="active">Active</option><option value="inactive">Inactive</option></select></label>
249
- <label><span class="sr-only">Category hierarchy</span><select x-model="hierarchyFilter" 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">Any hierarchy</option><option value="root">Root categories</option><option value="child">Child categories</option></select></label>
250
- <label><span class="sr-only">Sort product categories</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="order">Display order</option><option value="name">Name</option><option value="newest">Newest</option></select></label>
243
+ <div class="sm:col-span-2"><SearchFilter v-model:searchValue="search" placeholder="Search names, slugs, or descriptions" ariaLabel="Search product categories" /></div>
244
+ <Select v-model:value="activeFilter" ariaLabel="Category availability" placeholder="" :options="[{ value: 'all', label: 'Any availability' }, { value: 'active', label: 'Active' }, { value: 'inactive', label: 'Inactive' }]" />
245
+ <Select v-model:value="hierarchyFilter" ariaLabel="Category hierarchy" placeholder="" :options="[{ value: 'all', label: 'Any hierarchy' }, { value: 'root', label: 'Root categories' }, { value: 'child', label: 'Child categories' }]" />
246
+ <Select v-model:value="sort" ariaLabel="Sort product categories" placeholder="" :options="[{ value: 'order', label: 'Display order' }, { value: 'name', label: 'Name' }, { value: 'newest', label: 'Newest' }]" />
251
247
  </div>
252
248
 
253
249
  <div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
@@ -10,7 +10,7 @@ const busy = useReactiveProp('busy', false)
10
10
  const errors = useReactiveProp('errors', {} as Record<string, string>)
11
11
  const emit = defineEmits(['submit', 'close'])
12
12
  const name = state('')
13
- const description = state('')
13
+ const descriptionText = state('')
14
14
  const slug = state('')
15
15
  const imageUrl = state('')
16
16
  const isActive = state(true)
@@ -30,7 +30,7 @@ effect(() => {
30
30
  return
31
31
  hydrationKey = key
32
32
  name.set(current?.name || '')
33
- description.set(current?.description || '')
33
+ descriptionText.set(current?.description || '')
34
34
  slug.set(current?.slug || '')
35
35
  imageUrl.set(current?.imageUrl || '')
36
36
  isActive.set(current?.isActive ?? true)
@@ -94,7 +94,7 @@ function submit(): void {
94
94
  return
95
95
  emit('submit', {
96
96
  name: name().trim(),
97
- description: description().trim(),
97
+ description: descriptionText().trim(),
98
98
  slug: slugify(slug()),
99
99
  imageUrl: imageUrl().trim(),
100
100
  isActive: isActive(),
@@ -121,12 +121,12 @@ function errorMessages(): string[] {
121
121
  <li :for="message in errorMessages()" :key="message">{{ message }}</li>
122
122
  </ul>
123
123
  <div class="grid gap-4 grid-cols-1 sm:grid-cols-2">
124
- <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Name</span><input x-model="name" type="text" maxlength="50" 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" /></label>
125
- <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Slug</span><input x-model="slug" type="text" required spellcheck="false" class="mt-1 px-3 py-2 w-full font-mono text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700" @input="markSlugTouched" @blur="normalizeSlug" /></label>
126
- <label class="block sm:col-span-2"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Description</span><textarea x-model="description" rows="3" 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"></textarea></label>
127
- <label class="block sm:col-span-2"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Image URL</span><input x-model="imageUrl" type="text" placeholder="Optional persisted asset URL" 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" /><span class="block mt-1 text-gray-500 text-xs dark:text-neutral-500">Use a stored asset URL. File uploads belong to the native storage workflow.</span></label>
128
- <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Parent category</span><select x-model="parentCategoryId" 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"><option value="">Root category</option><option :for="option in parentOptions()" :key="option.id" :value="option.id">{{ option.name }}</option></select></label>
129
- <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Display order</span><input x-model="displayOrder" type="number" min="0" step="1" 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" /></label>
124
+ <Input v-model:value="name" label="Name" :maxLength="50" :required="true" />
125
+ <Input v-model:value="slug" label="Slug" :required="true" :spellcheck="false" :monospace="true" @input="markSlugTouched" @blur="normalizeSlug" />
126
+ <div class="sm:col-span-2"><Textarea v-model:value="descriptionText" label="Description" :rows="3" /></div>
127
+ <div class="sm:col-span-2"><Input v-model:value="imageUrl" label="Image URL" placeholder="Optional persisted asset URL" hint="Use a stored asset URL. File uploads belong to the native storage workflow." /></div>
128
+ <Select v-model:value="parentCategoryId" label="Parent category" placeholder="" :options="[{ value: '', label: 'Root category' }, ...parentOptions().map(option => ({ value: option.id, label: option.name }))]" />
129
+ <Input v-model:value="displayOrder" label="Display order" type="number" min="0" step="1" :required="true" />
130
130
  <div class="sm:col-span-2 p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
131
131
  <Toggle v-model:checked="isActive" label="Active in the storefront" description="Availability is independent from the hierarchy." labelPosition="left" />
132
132
  </div>
@@ -15,7 +15,7 @@ const busy = useReactiveProp('busy', false)
15
15
  const errors = useReactiveProp('errors', {} as Record<string, string>)
16
16
  const emit = defineEmits(['submit', 'close'])
17
17
  const code = state('')
18
- const description = state('')
18
+ const descriptionText = state('')
19
19
  const status = state<CouponStatus>('Active')
20
20
  const isActive = state(true)
21
21
  const discountType = state<CouponDiscountType>('percentage')
@@ -39,7 +39,7 @@ effect(() => {
39
39
  return
40
40
  hydrationKey = key
41
41
  code.set(current?.code || '')
42
- description.set(current?.description || '')
42
+ descriptionText.set(current?.description || '')
43
43
  status.set(current?.status || 'Active')
44
44
  isActive.set(current?.isActive ?? true)
45
45
  discountType.set(current?.discountType || 'percentage')
@@ -88,7 +88,7 @@ function submit(): void {
88
88
  return
89
89
  emit('submit', {
90
90
  code: code().trim().toUpperCase(),
91
- description: description().trim(),
91
+ description: descriptionText().trim(),
92
92
  status: status(),
93
93
  isActive: isActive(),
94
94
  discountType: discountType(),
@@ -121,17 +121,17 @@ function errorMessages(): string[] {
121
121
  <li :for="message in errorMessages()" :key="message">{{ message }}</li>
122
122
  </ul>
123
123
  <div class="grid gap-4 grid-cols-1 sm:grid-cols-2">
124
- <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Code</span><input x-model="code" type="text" maxlength="50" required spellcheck="false" class="mt-1 px-3 py-2 w-full font-mono text-gray-900 text-sm uppercase dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700" /></label>
125
- <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Status</span><select x-model="status" 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"><option value="Active">Active</option><option value="Scheduled">Scheduled</option><option value="Expired">Expired</option></select></label>
126
- <label class="block sm:col-span-2"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Description</span><textarea x-model="description" rows="3" 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"></textarea></label>
127
- <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Discount type</span><select x-model="discountType" 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"><option value="percentage">Percentage</option><option value="fixed_amount">Fixed amount</option></select></label>
128
- <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Discount value</span><input x-model="discountValue" type="number" :min="discountType() === 'fixed_amount' ? '0' : '0.01'" :step="discountType() === 'fixed_amount' ? moneyInputStep(currency()) : '0.01'" 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" /></label>
129
- <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Minimum order amount</span><input x-model="minOrderAmount" type="number" min="0" :step="moneyInputStep(currency())" placeholder="No minimum" 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" /></label>
130
- <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Maximum discount amount</span><input x-model="maxDiscountAmount" type="number" min="0" :step="moneyInputStep(currency())" placeholder="No maximum" 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" /></label>
131
- <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Usage limit</span><input x-model="usageLimit" type="number" min="1" step="1" placeholder="No limit" 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" /></label>
132
- <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Free product ID</span><input x-model="freeProductId" type="text" placeholder="Optional" class="mt-1 px-3 py-2 w-full font-mono text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700" /></label>
133
- <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Start date</span><input x-model="startDate" type="date" 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" /></label>
134
- <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">End date</span><input x-model="endDate" type="date" 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" /></label>
124
+ <Input v-model:value="code" label="Code" :maxLength="50" :required="true" :spellcheck="false" :monospace="true" class="uppercase" />
125
+ <Select v-model:value="status" label="Status" placeholder="" :options="[{ value: 'Active', label: 'Active' }, { value: 'Scheduled', label: 'Scheduled' }, { value: 'Expired', label: 'Expired' }]" />
126
+ <div class="sm:col-span-2"><Textarea v-model:value="descriptionText" label="Description" :rows="3" /></div>
127
+ <Select v-model:value="discountType" label="Discount type" placeholder="" :options="[{ value: 'percentage', label: 'Percentage' }, { value: 'fixed_amount', label: 'Fixed amount' }]" />
128
+ <Input v-model:value="discountValue" label="Discount value" type="number" :min="discountType() === 'fixed_amount' ? '0' : '0.01'" :step="discountType() === 'fixed_amount' ? moneyInputStep(currency()) : '0.01'" :required="true" />
129
+ <Input v-model:value="minOrderAmount" label="Minimum order amount" type="number" min="0" :step="moneyInputStep(currency())" placeholder="No minimum" />
130
+ <Input v-model:value="maxDiscountAmount" label="Maximum discount amount" type="number" min="0" :step="moneyInputStep(currency())" placeholder="No maximum" />
131
+ <Input v-model:value="usageLimit" label="Usage limit" type="number" min="1" step="1" placeholder="No limit" />
132
+ <Input v-model:value="freeProductId" label="Free product ID" placeholder="Optional" :monospace="true" />
133
+ <Input v-model:value="startDate" label="Start date" type="date" />
134
+ <Input v-model:value="endDate" label="End date" type="date" />
135
135
  <div class="sm:col-span-2 p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
136
136
  <Toggle v-model:checked="isActive" label="Enabled for redemption" description="Availability is stored separately from lifecycle status." labelPosition="left" />
137
137
  </div>