@stacksjs/defaults 0.75.569 → 0.75.572

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 (77) hide show
  1. package/ai/skills/stacks-actions/SKILL.md +1 -1
  2. package/ai/skills/stacks-cms/SKILL.md +1 -1
  3. package/ai/skills/stacks-dashboard/SKILL.md +283 -12
  4. package/ai/skills/stacks-database/SKILL.md +50 -0
  5. package/ai/skills/stacks-http/SKILL.md +33 -2
  6. package/ai/skills/stacks-native/CATALOG.md +8 -8
  7. package/ai/skills/stacks-orm/SKILL.md +20 -10
  8. package/ai/skills/stacks-query-builder/SKILL.md +7 -0
  9. package/app/Actions/Dashboard/Commerce/commerce-sql.ts +1 -1
  10. package/app/Actions/Dashboard/Content/CommentUpdateAction.ts +1 -1
  11. package/app/Actions/Dashboard/Content/PostStoreAction.ts +1 -1
  12. package/app/Actions/Dashboard/Content/PostUpdateAction.ts +1 -1
  13. package/app/Actions/Dashboard/Content/comment-list.ts +2 -2
  14. package/app/Actions/Dashboard/Content/page-list.ts +2 -2
  15. package/app/Actions/Dashboard/Content/post-list.ts +2 -2
  16. package/app/Actions/Dashboard/Infrastructure/InsightsAction.ts +24 -19
  17. package/app/Actions/Dashboard/Infrastructure/log-provider.ts +4 -4
  18. package/app/Actions/Dashboard/Jobs/job-list.ts +1 -1
  19. package/app/Actions/Dashboard/Kanban/BoardShowAction.ts +2 -2
  20. package/app/Actions/Dashboard/Kanban/CardShowAction.ts +3 -3
  21. package/app/Actions/Dashboard/Kanban/card-attachments.ts +1 -1
  22. package/app/Actions/Dashboard/Marketing/marketing-list-records.test.ts +2 -2
  23. package/app/Actions/Dashboard/Marketing/marketing-list-records.ts +4 -4
  24. package/app/Actions/Dashboard/Models/ModelShowAction.ts +42 -43
  25. package/app/Actions/Dashboard/Models/ModelUpdateAction.ts +17 -3
  26. package/app/Actions/Dashboard/Models/model-filters.ts +429 -0
  27. package/app/Actions/Dashboard/Models/model-switches.ts +159 -0
  28. package/app/Actions/Dashboard/Models/model-write.ts +6 -0
  29. package/app/Actions/Dashboard/Notifications/NotificationDeliveryOverviewAction.ts +1 -1
  30. package/app/Actions/Dashboard/Queries/query-list.ts +1 -1
  31. package/app/Actions/Dashboard/Queue/queue-stats.ts +2 -2
  32. package/app/Actions/Dashboard/named-search.ts +1 -1
  33. package/app/Models/Comment.ts +3 -3
  34. package/app/Models/Content/Post.ts +3 -3
  35. package/app/Models/EmailList.ts +8 -6
  36. package/app/Models/Subscriber.ts +2 -0
  37. package/app/Models/Team.ts +2 -0
  38. package/app/Models/User.ts +3 -0
  39. package/functions/dashboard-model-filters.ts +219 -0
  40. package/functions/dashboard-model-record.ts +42 -8
  41. package/ide/vscode/package.json +1 -1
  42. package/package.json +3 -3
  43. package/resources/components/Dashboard/Commerce/CommerceCategoryDialog.stx +3 -1
  44. package/resources/components/Dashboard/Commerce/CommerceCouponDialog.stx +3 -1
  45. package/resources/components/Dashboard/Commerce/CommerceGiftCardDialog.stx +9 -3
  46. package/resources/components/Dashboard/Commerce/CommerceManufacturerDialog.stx +3 -4
  47. package/resources/components/Dashboard/Commerce/CommerceProductDialog.stx +3 -1
  48. package/resources/components/Dashboard/Commerce/CommerceReviewEditDialog.stx +6 -8
  49. package/resources/components/Dashboard/Commerce/CommerceTaxDialog.stx +6 -14
  50. package/resources/components/Dashboard/Commerce/CommerceUnitDialog.stx +3 -7
  51. package/resources/components/Dashboard/Commerce/Delivery/DigitalDeliveryDialog.stx +6 -2
  52. package/resources/components/Dashboard/Content/BlogPostEditorDialog.stx +2 -8
  53. package/resources/components/Dashboard/Content/PageEditorDialog.stx +3 -7
  54. package/resources/components/Dashboard/Content/PostEditorDialog.stx +3 -4
  55. package/resources/components/Dashboard/Data/DataModelRecords.stx +12 -75
  56. package/resources/components/Dashboard/Data/DataStatCards.stx +110 -0
  57. package/resources/components/Dashboard/Email/InboxSettingsDashboard.stx +20 -36
  58. package/resources/components/Dashboard/Marketing/MarketingListDialog.stx +7 -14
  59. package/resources/components/Dashboard/Marketing/MarketingListsDashboard.stx +3 -2
  60. package/resources/components/Dashboard/Models/ModelFieldInputs.stx +10 -13
  61. package/resources/components/Dashboard/Models/ModelFilterPanel.stx +166 -0
  62. package/resources/components/Dashboard/Models/ModelRecordDetail.stx +18 -0
  63. package/resources/components/Dashboard/Models/ModelRecordEdit.stx +3 -2
  64. package/resources/components/Dashboard/Models/ModelRecordsDashboard.stx +96 -29
  65. package/resources/components/Dashboard/Models/ModelRegion.stx +25 -0
  66. package/resources/components/Dashboard/Models/ModelRegionFor.stx +31 -0
  67. package/resources/components/Dashboard/Operations/RecoveryDestinationDialog.stx +2 -2
  68. package/resources/components/Dashboard/Operations/RecoveryPolicyDialog.stx +3 -1
  69. package/resources/components/Dashboard/Operations/RecoveryRestoreDialog.stx +3 -1
  70. package/resources/components/Dashboard/Settings/AppearanceSettingsDashboard.stx +11 -14
  71. package/resources/components/Dashboard/Settings/SettingsDashboard.stx +6 -9
  72. package/resources/components/Dashboard/UI/Toggle.stx +16 -12
  73. package/resources/functions/dashboard/regions.ts +113 -0
  74. package/resources/functions/dashboard/sidebar.ts +2 -0
  75. package/views/dashboard/composables/useModelList.ts +52 -0
  76. package/views/dashboard/composables/useModelRecord.ts +46 -0
  77. package/views/dashboard/stores/model-page.ts +105 -0
@@ -117,24 +117,26 @@ export default defineModel({
117
117
  factory: faker => faker.helpers.arrayElement(['active', 'active', 'active', 'inactive']),
118
118
  },
119
119
 
120
+ // Yes or no, and declared as one: a switch in a form, `true` or `false`
121
+ // in a query. Declared as a number, the form asked for 0 or 1.
120
122
  isPublic: {
121
123
  required: false,
122
124
  fillable: true,
123
- default: 1,
125
+ default: true,
124
126
  validation: {
125
- rule: schema.number(),
127
+ rule: schema.boolean(),
126
128
  },
127
- factory: faker => faker.number.int({ min: 0, max: 1 }),
129
+ factory: faker => faker.datatype.boolean(),
128
130
  },
129
131
 
130
132
  doubleOptIn: {
131
133
  required: false,
132
134
  fillable: true,
133
- default: 1,
135
+ default: true,
134
136
  validation: {
135
- rule: schema.number(),
137
+ rule: schema.boolean(),
136
138
  },
137
- factory: () => 1,
139
+ factory: () => true,
138
140
  },
139
141
  },
140
142
 
@@ -91,5 +91,7 @@ export default defineModel({
91
91
 
92
92
  dashboard: {
93
93
  columns: ['email', 'status', 'source', 'user', 'createdAt'],
94
+ // The row of numbers above the list: subscribed, unsubscribed, new.
95
+ regions: { listTop: 'DataStatCards' },
94
96
  },
95
97
  } as const)
@@ -76,6 +76,8 @@ export default defineModel({
76
76
 
77
77
  dashboard: {
78
78
  columns: ['name', 'memberCount', 'status', 'createdAt'],
79
+ // The row of numbers above the list: teams, active ones, members.
80
+ regions: { listTop: 'DataStatCards' },
79
81
  // A count of members is called what it counts.
80
82
  fields: {
81
83
  memberCount: { label: 'Members' },
@@ -165,6 +165,9 @@ export default defineModel({
165
165
  // The list is for telling accounts apart. The two-factor step, the
166
166
  // billing id and the rest are on the account's own page.
167
167
  columns: ['name', 'email', 'emailVerifiedAt', 'createdAt'],
168
+ // The row of numbers above the list: how many, how many are new, how
169
+ // many confirmed their email.
170
+ regions: { listTop: 'DataStatCards' },
168
171
  // An avatar is a picture, not the address of one.
169
172
  fields: {
170
173
  // Chosen as a file, and shown as the picture it is.
@@ -0,0 +1,219 @@
1
+ /**
2
+ * A list's filters, on the page: what each one's value looks like, how it is
3
+ * worded, and how the days a person picks become what the server compares.
4
+ *
5
+ * The server says which filters a model's list has and what kind each is
6
+ * (`Models/model-filters.ts`: derived from the model's fields, never
7
+ * declared one by one). Nothing here knows a model; it knows the kinds.
8
+ */
9
+
10
+ /** How a filter is asked for. Matches the server's `ModelFilterKind`. */
11
+ export type ModelListFilterKind = 'choice' | 'boolean' | 'relation' | 'date' | 'datetime' | 'number' | 'text'
12
+
13
+ export interface ModelListFilter {
14
+ /** The column it narrows. */
15
+ name: string
16
+ label: string
17
+ kind: ModelListFilterKind
18
+ options?: Array<{ value: string, label: string }>
19
+ /** The options are what the table holds now, not all the field may ever hold. */
20
+ open?: boolean
21
+ relation?: { slug: string, label: string }
22
+ }
23
+
24
+ /**
25
+ * A filter's value. Text is "exactly this"; the rest say how: any of
26
+ * several, between two days, between two numbers.
27
+ */
28
+ export type ModelListFilterValue = string | { in: string[] } | { from?: string, to?: string } | { min?: number, max?: number }
29
+
30
+ export type ModelListFilterValues = Record<string, ModelListFilterValue>
31
+
32
+ function isRecord(value: unknown): value is Record<string, unknown> {
33
+ return Boolean(value) && typeof value === 'object' && !Array.isArray(value)
34
+ }
35
+
36
+ /** One value from an address, or null when it is not a shape a filter has. */
37
+ export function modelFilterValue(value: unknown): ModelListFilterValue | null {
38
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean')
39
+ return String(value) === '' ? null : String(value)
40
+ if (!isRecord(value))
41
+ return null
42
+ const keys = Object.keys(value)
43
+ if (keys.length === 1 && keys[0] === 'in') {
44
+ const list = Array.isArray(value.in) ? value.in.filter(item => typeof item === 'string' || typeof item === 'number').map(String).filter(item => item !== '') : []
45
+ return list.length > 0 ? { in: [...new Set(list)] } : null
46
+ }
47
+ if (keys.length > 0 && keys.every(key => key === 'from' || key === 'to')) {
48
+ const range: { from?: string, to?: string } = {}
49
+ if (typeof value.from === 'string' && value.from !== '')
50
+ range.from = value.from
51
+ if (typeof value.to === 'string' && value.to !== '')
52
+ range.to = value.to
53
+ return range.from !== undefined || range.to !== undefined ? range : null
54
+ }
55
+ if (keys.length > 0 && keys.every(key => key === 'min' || key === 'max')) {
56
+ const range: { min?: number, max?: number } = {}
57
+ for (const edge of ['min', 'max'] as const) {
58
+ const amount = value[edge]
59
+ const number = typeof amount === 'number' ? amount : typeof amount === 'string' && amount.trim() !== '' ? Number(amount) : Number.NaN
60
+ if (Number.isFinite(number))
61
+ range[edge] = number
62
+ }
63
+ return range.min !== undefined || range.max !== undefined ? range : null
64
+ }
65
+ return null
66
+ }
67
+
68
+ /** Whether a filter narrows anything. An empty box, list or range does not. */
69
+ export function modelFilterIsSet(value: ModelListFilterValue | undefined | null): boolean {
70
+ return value !== undefined && value !== null && modelFilterValue(value) !== null
71
+ }
72
+
73
+ /** The filters that narrow something, as the list sends them and its address carries them. */
74
+ export function modelFiltersSet(values: ModelListFilterValues): ModelListFilterValues {
75
+ const out: ModelListFilterValues = {}
76
+ for (const [column, value] of Object.entries(values)) {
77
+ const read = modelFilterValue(value)
78
+ if (read !== null)
79
+ out[column] = read
80
+ }
81
+ return out
82
+ }
83
+
84
+ /** The values a choice filter has picked. */
85
+ export function modelFilterChosen(value: ModelListFilterValue | undefined): string[] {
86
+ if (typeof value === 'string')
87
+ return value === '' ? [] : [value]
88
+ return value && 'in' in value ? value.in : []
89
+ }
90
+
91
+ /** Pick or unpick one option of a choice filter. Unpicking the last one clears the filter. */
92
+ export function modelFilterToggle(value: ModelListFilterValue | undefined, option: string): ModelListFilterValue {
93
+ const chosen = modelFilterChosen(value)
94
+ const next = chosen.includes(option) ? chosen.filter(item => item !== option) : [...chosen, option]
95
+ return next.length === 0 ? '' : { in: next }
96
+ }
97
+
98
+ function pad(number: number): string {
99
+ return String(number).padStart(2, '0')
100
+ }
101
+
102
+ /** A date as the day it is where the viewer is: `2026-01-31`. */
103
+ export function modelFilterDay(date: Date): string {
104
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`
105
+ }
106
+
107
+ /** The start of a day where the viewer is, or null when it is not a day. */
108
+ function startOfDay(day: string): Date | null {
109
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(day)
110
+ if (!match)
111
+ return null
112
+ const date = new Date(Number(match[1]), Number(match[2]) - 1, Number(match[3]))
113
+ return Number.isNaN(date.getTime()) || modelFilterDay(date) !== day ? null : date
114
+ }
115
+
116
+ /**
117
+ * The value a range of days narrows by.
118
+ *
119
+ * A date column stores days, so the days go as they are, both included. A
120
+ * moment is stored as an instant, and "the 5th" is a different stretch of
121
+ * instants in Manila than in London: the page sends where the viewer's first
122
+ * day starts and where the day after their last one does.
123
+ */
124
+ export function modelFilterRange(kind: 'date' | 'datetime', from: string, to: string): ModelListFilterValue {
125
+ const first = startOfDay(from)
126
+ const last = startOfDay(to)
127
+ if (!first && !last)
128
+ return ''
129
+ if (kind === 'date')
130
+ return { ...(first ? { from } : {}), ...(last ? { to } : {}) }
131
+ const range: { from?: string, to?: string } = {}
132
+ if (first)
133
+ range.from = first.toISOString()
134
+ if (last)
135
+ range.to = new Date(last.getFullYear(), last.getMonth(), last.getDate() + 1).toISOString()
136
+ return range
137
+ }
138
+
139
+ /** The days a range filter is showing in its two date boxes. */
140
+ export function modelFilterDays(kind: 'date' | 'datetime', value: ModelListFilterValue | undefined): { from: string, to: string } {
141
+ if (!value || typeof value === 'string' || !('from' in value || 'to' in value))
142
+ return { from: '', to: '' }
143
+ const range = value as { from?: string, to?: string }
144
+ if (kind === 'date')
145
+ return { from: range.from ?? '', to: range.to ?? '' }
146
+ const from = range.from ? new Date(range.from) : null
147
+ const to = range.to ? new Date(range.to) : null
148
+ return {
149
+ from: from && !Number.isNaN(from.getTime()) ? modelFilterDay(from) : '',
150
+ // The instant sent is the start of the day after the last one.
151
+ to: to && !Number.isNaN(to.getTime()) ? modelFilterDay(new Date(to.getTime() - 1)) : '',
152
+ }
153
+ }
154
+
155
+ /** The ranges offered in one press. */
156
+ export const MODEL_FILTER_PRESETS = [
157
+ { name: 'today', label: 'Today' },
158
+ { name: 'week', label: 'Last 7 days' },
159
+ { name: 'month', label: 'This month' },
160
+ ] as const
161
+
162
+ export type ModelFilterPreset = typeof MODEL_FILTER_PRESETS[number]['name']
163
+
164
+ /** The first and last day of a preset, as of `now`. */
165
+ export function modelFilterPresetDays(preset: ModelFilterPreset, now: Date = new Date()): { from: string, to: string } {
166
+ const today = modelFilterDay(now)
167
+ if (preset === 'today')
168
+ return { from: today, to: today }
169
+ if (preset === 'week')
170
+ return { from: modelFilterDay(new Date(now.getFullYear(), now.getMonth(), now.getDate() - 6)), to: today }
171
+ return { from: modelFilterDay(new Date(now.getFullYear(), now.getMonth(), 1)), to: today }
172
+ }
173
+
174
+ /** A day as a sentence has it: "Jan 31, 2026". */
175
+ function wordedDay(day: string): string {
176
+ const date = startOfDay(day)
177
+ return date ? date.toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' }) : day
178
+ }
179
+
180
+ /**
181
+ * What an active filter says in its chip: "Active, Pending", "from Jan 1,
182
+ * 2026", "at least 10". `names` words a record a relation filter points at;
183
+ * without one it is named by its id, which is still true.
184
+ */
185
+ export function modelFilterSummary(filter: ModelListFilter | undefined, value: ModelListFilterValue, names: Record<string, string> = {}): string {
186
+ const worded = (stored: string): string => {
187
+ if (filter?.kind === 'relation')
188
+ return names[stored] ?? `#${stored}`
189
+ if (filter?.kind === 'boolean')
190
+ return ['true', '1', 'yes'].includes(stored.toLowerCase()) ? 'Yes' : 'No'
191
+ return filter?.options?.find(option => option.value === stored)?.label ?? names[stored] ?? stored
192
+ }
193
+ if (typeof value === 'string')
194
+ return worded(value)
195
+ if ('in' in value)
196
+ return value.in.map(worded).join(', ')
197
+ if ('from' in value || 'to' in value) {
198
+ const days = modelFilterDays(filter?.kind === 'date' ? 'date' : 'datetime', value)
199
+ if (days.from && days.to)
200
+ return days.from === days.to ? wordedDay(days.from) : `${wordedDay(days.from)} to ${wordedDay(days.to)}`
201
+ return days.from ? `from ${wordedDay(days.from)}` : `until ${wordedDay(days.to)}`
202
+ }
203
+ const range = value as { min?: number, max?: number }
204
+ if (range.min !== undefined && range.max !== undefined)
205
+ return `${range.min.toLocaleString()} to ${range.max.toLocaleString()}`
206
+ return range.min !== undefined ? `at least ${range.min.toLocaleString()}` : `at most ${(range.max ?? 0).toLocaleString()}`
207
+ }
208
+
209
+ /** A list's address with what narrows it: `?q=ava&filters={...}`. Nothing else is kept. */
210
+ export function modelListAddress(path: string, search: string, values: ModelListFilterValues): string {
211
+ const params = new URLSearchParams()
212
+ if (search.trim())
213
+ params.set('q', search.trim())
214
+ const set = modelFiltersSet(values)
215
+ if (Object.keys(set).length > 0)
216
+ params.set('filters', JSON.stringify(set))
217
+ const query = params.toString()
218
+ return query ? `${path}?${query}` : path
219
+ }
@@ -15,6 +15,8 @@ import { DashboardApiError, dashboardApi } from './dashboard-api'
15
15
  import { parseDashboardDate } from './dashboard-dates'
16
16
  import type { ModelFieldDisplay } from './dashboard-model-format'
17
17
  import type { ModelBadgeTone } from './dashboard-model-format'
18
+ import type { ModelListFilterValues } from './dashboard-model-filters'
19
+ import { modelFilterValue } from './dashboard-model-filters'
18
20
  import { MODEL_BADGE_COLUMNS, modelBadgeTone, modelColumnIsDate, modelFormattedValue } from './dashboard-model-format'
19
21
 
20
22
  export interface ModelWriteCapabilities {
@@ -136,9 +138,17 @@ export interface ModelCreateField {
136
138
  help?: string
137
139
  /** For an `upload`: the kinds of file that may be chosen, as a file input's `accept` spells them. */
138
140
  accept?: string
141
+ /**
142
+ * A yes or no the application keeps for itself (a confirmed email,
143
+ * two-factor), offered as a switch: the one way it can be turned, when it
144
+ * has only one, and what is said under it while it cannot be.
145
+ */
146
+ switch?: { only?: 'off' | 'on', lockedHelp?: string }
147
+ /** Shown but not to be changed: a switch that cannot be turned from where it is. */
148
+ disabled?: boolean
139
149
  }
140
150
 
141
- /** What a form holds for each field: a checkbox's state, or an input's text. */
151
+ /** What a form holds for each field: a switch's state, or an input's text. */
142
152
  export type ModelFormValues = Record<string, string | boolean>
143
153
 
144
154
  export interface ModelCreateForm {
@@ -442,6 +452,9 @@ function localMoment(stored: unknown): string {
442
452
  * of braces in plain text boxes.
443
453
  */
444
454
  export function modelFieldInputValue(field: ModelCreateField, stored: unknown): string | boolean {
455
+ // A switch reads yes from whatever marks it: a moment that is set, a true, a one.
456
+ if (field.switch)
457
+ return !(stored === null || stored === undefined || stored === false || stored === 0 || stored === '' || stored === '0' || stored === 'false')
445
458
  if (field.type === 'boolean')
446
459
  return stored === true || stored === 1 || stored === '1' || stored === 'true'
447
460
  if (stored === null || stored === undefined || stored === '')
@@ -496,6 +509,21 @@ export function modelFormValues(fields: ModelCreateField[], row?: Record<string,
496
509
  ]))
497
510
  }
498
511
 
512
+ /**
513
+ * The form's fields for a record as it is stored. A switch that can only be
514
+ * turned one way is shown but not offered once it is already there:
515
+ * two-factor can be turned off for someone, never on. It then says why
516
+ * instead of what turning it would do.
517
+ */
518
+ export function modelFormFieldsFor(fields: ModelCreateField[], stored: ModelFormValues): ModelCreateField[] {
519
+ return fields.map((field) => {
520
+ const only = field.switch?.only
521
+ if (!only || (stored[field.name] === true) === (only === 'off'))
522
+ return field
523
+ return { ...field, disabled: true, ...(field.switch?.lockedHelp ? { help: field.switch.lockedHelp } : {}) }
524
+ })
525
+ }
526
+
499
527
  /**
500
528
  * What a form sends. Given what it started with, only the fields that were
501
529
  * changed: a value the editor merely displayed is never written back.
@@ -799,7 +827,7 @@ export async function fetchModelOptions(slug: string, search: { q?: string, ids?
799
827
  * when the model left it out: a list opened from a record's panel arrives
800
828
  * narrowed by that record, and what narrowed it has to be in view to clear.
801
829
  */
802
- export function modelListColumnNames(all: string[], chosen: string[] | undefined, filters: Record<string, string> = {}): string[] {
830
+ export function modelListColumnNames(all: string[], chosen: string[] | undefined, filters: Record<string, unknown> = {}): string[] {
803
831
  const list = chosen && chosen.length > 0 ? chosen.filter(column => all.includes(column)) : all
804
832
  const filtered = Object.entries(filters).filter(([column, value]) => value !== '' && all.includes(column) && !list.includes(column)).map(([column]) => column)
805
833
  return [...list, ...filtered]
@@ -932,19 +960,25 @@ export function modelRelatedCreateHref(panel: ModelRelatedPanel, parentId: strin
932
960
  }
933
961
 
934
962
  /**
935
- * The filters a list starts with, from its address: `?filters={"team_id":"3"}`.
936
- * Anything that is not a flat object of text is ignored, never trusted.
963
+ * The filters a list starts with, from its address: `?filters={"team_id":"3"}`
964
+ * or `{"status":{"in":["active","pending"]}}`. A column or a value that is
965
+ * not a shape a filter has is ignored, never trusted.
937
966
  */
938
- export function modelListFilters(raw: string | null): Record<string, string> {
967
+ export function modelListFilters(raw: string | null): ModelListFilterValues {
939
968
  if (!raw)
940
969
  return {}
941
970
  try {
942
971
  const parsed = JSON.parse(raw) as unknown
943
972
  if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
944
973
  return {}
945
- return Object.fromEntries(Object.entries(parsed as Record<string, unknown>)
946
- .filter(([column, value]) => /^[a-z_][a-z0-9_]*$/i.test(column) && (typeof value === 'string' || typeof value === 'number') && String(value) !== '')
947
- .map(([column, value]) => [column, String(value)]))
974
+ const out: ModelListFilterValues = {}
975
+ for (const [column, value] of Object.entries(parsed as Record<string, unknown>)) {
976
+ // A yes-or-no is not something an address is trusted to carry as true.
977
+ const read = typeof value === 'boolean' ? null : modelFilterValue(value)
978
+ if (/^[a-z_][a-z0-9_]*$/i.test(column) && read !== null)
979
+ out[column] = read
980
+ }
981
+ return out
948
982
  }
949
983
  catch {
950
984
  return {}
@@ -2,7 +2,7 @@
2
2
  "publisher": "Stacks",
3
3
  "name": "vscode-stacks",
4
4
  "displayName": "Stacks",
5
- "version": "0.75.569",
5
+ "version": "0.75.572",
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.569",
5
+ "version": "0.75.572",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/stacksjs/stacks.git",
@@ -45,10 +45,10 @@
45
45
  "dependencies": {
46
46
  "@iconify-json/f7": "^1.2.2",
47
47
  "@iconify-json/hugeicons": "^1.2.35",
48
- "@stacksjs/mobile": "0.75.569",
48
+ "@stacksjs/mobile": "0.75.572",
49
49
  "@stacksjs/sanitizer": "^0.2.864",
50
50
  "@stacksjs/stx": "^0.2.864",
51
- "@stacksjs/strings": "0.75.569",
51
+ "@stacksjs/strings": "0.75.572",
52
52
  "@xterm/addon-fit": "^0.11.0",
53
53
  "@xterm/xterm": "^6.0.0",
54
54
  "ts-qr-codes": "^0.1.8"
@@ -127,7 +127,9 @@ function errorMessages(): string[] {
127
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
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
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>
130
- <label class="flex gap-3 items-center sm:col-span-2 p-3 border border-gray-200 rounded-lg dark:border-neutral-700"><input x-model="isActive" type="checkbox" class="h-4 w-4 text-blue-600 border-gray-300 rounded" /><span><span class="block font-medium text-gray-700 text-sm dark:text-neutral-200">Active in the storefront</span><span class="block mt-0.5 text-gray-500 text-xs dark:text-neutral-500">Availability is independent from the hierarchy.</span></span></label>
130
+ <div class="sm:col-span-2 p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
131
+ <Toggle v-model:checked="isActive" label="Active in the storefront" description="Availability is independent from the hierarchy." labelPosition="left" />
132
+ </div>
131
133
  </div>
132
134
  </form>
133
135
  <template #footer>
@@ -132,7 +132,9 @@ function errorMessages(): string[] {
132
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
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
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>
135
- <label class="flex gap-3 items-center sm:col-span-2 p-3 border border-gray-200 rounded-lg dark:border-neutral-700"><input x-model="isActive" type="checkbox" class="h-4 w-4 text-blue-600 border-gray-300 rounded" /><span><span class="block font-medium text-gray-700 text-sm dark:text-neutral-200">Enabled for redemption</span><span class="block mt-0.5 text-gray-500 text-xs dark:text-neutral-500">Availability is stored separately from lifecycle status.</span></span></label>
135
+ <div class="sm:col-span-2 p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
136
+ <Toggle v-model:checked="isActive" label="Enabled for redemption" description="Availability is stored separately from lifecycle status." labelPosition="left" />
137
+ </div>
136
138
  </div>
137
139
  </form>
138
140
  <template #footer>
@@ -180,9 +180,15 @@ function errorMessages(): string[] {
180
180
  <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Customer ID</span><input x-model="customerId" type="number" min="1" step="1" placeholder="Optional" 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>
181
181
  <label class="block sm:col-span-2"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Template ID</span><input x-model="templateId" 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>
182
182
  <div class="grid gap-3 grid-cols-1 sm:col-span-2 sm:grid-cols-3">
183
- <label class="flex gap-3 items-center p-3 border border-gray-200 rounded-lg dark:border-neutral-700"><input x-model="isActive" type="checkbox" class="h-4 w-4 text-blue-600 border-gray-300 rounded" /><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Enabled</span></label>
184
- <label class="flex gap-3 items-center p-3 border border-gray-200 rounded-lg dark:border-neutral-700"><input x-model="isDigital" type="checkbox" class="h-4 w-4 text-blue-600 border-gray-300 rounded" /><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Digital delivery</span></label>
185
- <label class="flex gap-3 items-center p-3 border border-gray-200 rounded-lg dark:border-neutral-700"><input x-model="isReloadable" type="checkbox" class="h-4 w-4 text-blue-600 border-gray-300 rounded" /><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Reloadable</span></label>
183
+ <div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
184
+ <Toggle v-model:checked="isActive" label="Enabled" labelPosition="left" />
185
+ </div>
186
+ <div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
187
+ <Toggle v-model:checked="isDigital" label="Digital delivery" labelPosition="left" />
188
+ </div>
189
+ <div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
190
+ <Toggle v-model:checked="isReloadable" label="Reloadable" labelPosition="left" />
191
+ </div>
186
192
  </div>
187
193
  </div>
188
194
  </form>
@@ -70,10 +70,9 @@ function errorMessages(): string[] {
70
70
  <span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Country</span>
71
71
  <input x-model="country" type="text" maxlength="100" 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" />
72
72
  </label>
73
- <label class="flex gap-3 items-center p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
74
- <input x-model="featured" type="checkbox" class="h-4 w-4 text-blue-600 border-gray-300 rounded" />
75
- <span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Featured manufacturer</span>
76
- </label>
73
+ <div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
74
+ <Toggle v-model:checked="featured" label="Featured manufacturer" labelPosition="left" />
75
+ </div>
77
76
  </div>
78
77
  </form>
79
78
  <template #footer>
@@ -155,7 +155,9 @@ function errorMessages(): string[] {
155
155
  <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Price ({{ currency() }})</span><input x-model="price" type="number" min="0" :step="moneyInputStep(currency())" inputmode="decimal" required :aria-invalid="price() !== '' && priceError() !== ''" 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 :if="price() !== '' && priceError()" class="block mt-1 text-red-600 text-xs dark:text-red-400">{{ priceError() }}</span></label>
156
156
  <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Inventory count</span><input x-model="inventoryCount" 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>
157
157
  <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Preparation time (minutes)</span><input x-model="preparationTime" type="number" min="1" 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>
158
- <label class="flex gap-3 items-center self-end px-3 py-2 min-h-10 bg-gray-50 dark:bg-neutral-900/60 border border-gray-200 rounded-md dark:border-neutral-700"><input x-model="isAvailable" type="checkbox" class="h-4 w-4 text-blue-600 border-gray-300 rounded" /><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Available for commerce</span></label>
158
+ <div class="self-end px-3 py-2 min-h-10 bg-gray-50 dark:bg-neutral-900/60 border border-gray-200 rounded-md dark:border-neutral-700">
159
+ <Toggle v-model:checked="isAvailable" label="Available for commerce" labelPosition="left" />
160
+ </div>
159
161
  <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Category</span><select x-model="categoryId" 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="">Unassigned category</option><option :for="option in categories()" :key="option.id" :value="option.id">{{ option.label }}</option></select></label>
160
162
  <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Manufacturer</span><select x-model="manufacturerId" 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="">Unassigned manufacturer</option><option :for="option in manufacturers()" :key="option.id" :value="option.id">{{ option.label }}</option></select></label>
161
163
  <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="url" 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" /></label>
@@ -81,14 +81,12 @@ function errorMessages(): string[] {
81
81
  </select>
82
82
  </label>
83
83
  <div class="grid gap-3 grid-cols-1 sm:grid-cols-2">
84
- <label class="flex gap-3 items-center p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
85
- <input x-model="approved" type="checkbox" class="h-4 w-4 text-blue-600 border-gray-300 rounded" />
86
- <span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Approved</span>
87
- </label>
88
- <label class="flex gap-3 items-center p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
89
- <input x-model="featured" type="checkbox" class="h-4 w-4 text-blue-600 border-gray-300 rounded" />
90
- <span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Featured</span>
91
- </label>
84
+ <div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
85
+ <Toggle v-model:checked="approved" label="Approved" labelPosition="left" />
86
+ </div>
87
+ <div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
88
+ <Toggle v-model:checked="featured" label="Featured" labelPosition="left" />
89
+ </div>
92
90
  </div>
93
91
  </div>
94
92
  </form>
@@ -115,25 +115,17 @@ function errorMessages(): string[] {
115
115
  <input x-model="code" type="text" placeholder="sales" 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" />
116
116
  <span class="block mt-1 text-gray-500 text-xs dark:text-neutral-400">What the application matches on. Renaming the rate above does not change what is charged; changing this can.</span>
117
117
  </label>
118
- <label class="flex gap-3 items-start p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
119
- <input x-model="isDefault" type="checkbox" class="mt-0.5 h-4 w-4 text-blue-600 border-gray-300 rounded" />
120
- <span>
121
- <span class="block font-medium text-gray-700 text-sm dark:text-neutral-200">Default tax rate</span>
122
- <span class="block mt-0.5 text-gray-500 text-xs dark:text-neutral-400">Selecting this clears the default flag from every other rate.</span>
123
- </span>
124
- </label>
118
+ <div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
119
+ <Toggle v-model:checked="isDefault" label="Default tax rate" description="Selecting this clears the default flag from every other rate." labelPosition="left" />
120
+ </div>
125
121
  {{--
126
122
  Spelled out rather than labelled "exempt", because the two read
127
123
  alike and mean opposite things: this marks the component as one an
128
124
  exemption can lift, not one that is currently unpaid.
129
125
  --}}
130
- <label class="flex gap-3 items-start p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
131
- <input x-model="exemptible" type="checkbox" class="mt-0.5 h-4 w-4 text-blue-600 border-gray-300 rounded" />
132
- <span>
133
- <span class="block font-medium text-gray-700 text-sm dark:text-neutral-200">Can be exempted</span>
134
- <span class="block mt-0.5 text-gray-500 text-xs dark:text-neutral-400">Customers who qualify for an exemption are not charged this component. Leave off for anything owed regardless - an excise or a city levy is usually still due.</span>
135
- </span>
136
- </label>
126
+ <div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
127
+ <Toggle v-model:checked="exemptible" label="Can be exempted" description="Customers who qualify for an exemption are not charged this component. Leave off for anything owed regardless - an excise or a city levy is usually still due." labelPosition="left" />
128
+ </div>
137
129
  </div>
138
130
  </form>
139
131
  <template #footer>
@@ -152,13 +152,9 @@ function errorMessages(): string[] {
152
152
  <span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Description</span>
153
153
  <textarea x-model="description" rows="3" maxlength="255" 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>
154
154
  </label>
155
- <label class="flex gap-3 items-start p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
156
- <input x-model="isDefault" type="checkbox" class="mt-0.5 h-4 w-4 text-blue-600 border-gray-300 rounded" />
157
- <span>
158
- <span class="block font-medium text-gray-700 text-sm dark:text-neutral-200">Default for this type</span>
159
- <span class="block mt-0.5 text-gray-500 text-xs dark:text-neutral-400">Selecting this clears any other default in the same unit type.</span>
160
- </span>
161
- </label>
155
+ <div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
156
+ <Toggle v-model:checked="isDefault" label="Default for this type" description="Selecting this clears any other default in the same unit type." labelPosition="left" />
157
+ </div>
162
158
  </div>
163
159
  </form>
164
160
  <template #footer>
@@ -97,8 +97,12 @@ function submit(): void {
97
97
  <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Expiry days</span><input x-model="expiryDays" type="number" required min="0" step="1" inputmode="numeric" class="mt-1 px-3 py-2 w-full tabular-nums 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 0 for access without expiry.</span></label>
98
98
  </div>
99
99
  <div class="grid gap-3 grid-cols-1 sm:grid-cols-2">
100
- <label class="flex gap-3 items-start p-3 border border-gray-200 rounded-lg dark:border-neutral-700"><input x-model="requiresLogin" type="checkbox" class="mt-0.5 h-4 w-4 text-blue-600 bg-white dark:bg-neutral-900 border-gray-300 rounded dark:border-neutral-600" /><span><strong class="block text-gray-900 text-sm dark:text-white">Require login</strong><span class="block mt-0.5 text-gray-500 text-xs dark:text-neutral-400">Only authenticated customers can download.</span></span></label>
101
- <label class="flex gap-3 items-start p-3 border border-gray-200 rounded-lg dark:border-neutral-700"><input x-model="automaticDelivery" type="checkbox" class="mt-0.5 h-4 w-4 text-blue-600 bg-white dark:bg-neutral-900 border-gray-300 rounded dark:border-neutral-600" /><span><strong class="block text-gray-900 text-sm dark:text-white">Automatic delivery</strong><span class="block mt-0.5 text-gray-500 text-xs dark:text-neutral-400">Fulfill automatically after payment.</span></span></label>
100
+ <div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
101
+ <Toggle v-model:checked="requiresLogin" label="Require login" description="Only authenticated customers can download." labelPosition="left" />
102
+ </div>
103
+ <div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
104
+ <Toggle v-model:checked="automaticDelivery" label="Automatic delivery" description="Fulfill automatically after payment." labelPosition="left" />
105
+ </div>
102
106
  </div>
103
107
  <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="inactive">Inactive</option></select></label>
104
108
  </div>
@@ -177,14 +177,8 @@ function submit(): void {
177
177
  </div>
178
178
 
179
179
  <div class="flex flex-col gap-3 sm:flex-row sm:gap-6 pt-2 border-neutral-200 border-t dark:border-neutral-800">
180
- <label class="flex gap-2 items-center text-sm">
181
- <input x-model="draft" name="draft" type="checkbox" class="h-4 w-4 text-blue-600 border-neutral-300 rounded dark:border-neutral-600" />
182
- <span>Draft, keep off the public blog</span>
183
- </label>
184
- <label class="flex gap-2 items-center text-sm">
185
- <input x-model="featured" name="featured" type="checkbox" class="h-4 w-4 text-blue-600 border-neutral-300 rounded dark:border-neutral-600" />
186
- <span>Feature at the top of the listing</span>
187
- </label>
180
+ <Toggle v-model:checked="draft" name="draft" label="Draft, keep off the public blog" />
181
+ <Toggle v-model:checked="featured" name="featured" label="Feature at the top of the listing" />
188
182
  </div>
189
183
  </form>
190
184