@almadar/std 2.1.1 → 2.4.1
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.
- package/dist/behaviors/async.d.ts +12 -7
- package/dist/behaviors/async.js +1085 -312
- package/dist/behaviors/async.js.map +1 -1
- package/dist/behaviors/data-management.d.ts +27 -13
- package/dist/behaviors/data-management.js +600 -244
- package/dist/behaviors/data-management.js.map +1 -1
- package/dist/behaviors/domain/commerce.d.ts +51 -0
- package/dist/behaviors/domain/commerce.js +1093 -0
- package/dist/behaviors/domain/commerce.js.map +1 -0
- package/dist/behaviors/domain/content.d.ts +51 -0
- package/dist/behaviors/domain/content.js +1294 -0
- package/dist/behaviors/domain/content.js.map +1 -0
- package/dist/behaviors/domain/dashboard.d.ts +45 -0
- package/dist/behaviors/domain/dashboard.js +783 -0
- package/dist/behaviors/domain/dashboard.js.map +1 -0
- package/dist/behaviors/domain/education.d.ts +41 -0
- package/dist/behaviors/domain/education.js +738 -0
- package/dist/behaviors/domain/education.js.map +1 -0
- package/dist/behaviors/domain/finance.d.ts +49 -0
- package/dist/behaviors/domain/finance.js +660 -0
- package/dist/behaviors/domain/finance.js.map +1 -0
- package/dist/behaviors/domain/game-2d-platformer.d.ts +50 -0
- package/dist/behaviors/domain/game-2d-platformer.js +810 -0
- package/dist/behaviors/domain/game-2d-platformer.js.map +1 -0
- package/dist/behaviors/domain/game-2d-puzzle.d.ts +42 -0
- package/dist/behaviors/domain/game-2d-puzzle.js +622 -0
- package/dist/behaviors/domain/game-2d-puzzle.js.map +1 -0
- package/dist/behaviors/domain/game-2d-rpg.d.ts +48 -0
- package/dist/behaviors/domain/game-2d-rpg.js +860 -0
- package/dist/behaviors/domain/game-2d-rpg.js.map +1 -0
- package/dist/behaviors/domain/game-2d-strategy.d.ts +48 -0
- package/dist/behaviors/domain/game-2d-strategy.js +692 -0
- package/dist/behaviors/domain/game-2d-strategy.js.map +1 -0
- package/dist/behaviors/domain/geospatial.d.ts +35 -0
- package/dist/behaviors/domain/geospatial.js +634 -0
- package/dist/behaviors/domain/geospatial.js.map +1 -0
- package/dist/behaviors/domain/healthcare.d.ts +36 -0
- package/dist/behaviors/domain/healthcare.js +1068 -0
- package/dist/behaviors/domain/healthcare.js.map +1 -0
- package/dist/behaviors/domain/iot.d.ts +45 -0
- package/dist/behaviors/domain/iot.js +589 -0
- package/dist/behaviors/domain/iot.js.map +1 -0
- package/dist/behaviors/domain/media.d.ts +41 -0
- package/dist/behaviors/domain/media.js +771 -0
- package/dist/behaviors/domain/media.js.map +1 -0
- package/dist/behaviors/domain/scheduling.d.ts +41 -0
- package/dist/behaviors/domain/scheduling.js +930 -0
- package/dist/behaviors/domain/scheduling.js.map +1 -0
- package/dist/behaviors/domain/simulation.d.ts +36 -0
- package/dist/behaviors/domain/simulation.js +706 -0
- package/dist/behaviors/domain/simulation.js.map +1 -0
- package/dist/behaviors/domain/social.d.ts +41 -0
- package/dist/behaviors/domain/social.js +840 -0
- package/dist/behaviors/domain/social.js.map +1 -0
- package/dist/behaviors/domain/workflow.d.ts +41 -0
- package/dist/behaviors/domain/workflow.js +879 -0
- package/dist/behaviors/domain/workflow.js.map +1 -0
- package/dist/behaviors/feedback.d.ts +10 -5
- package/dist/behaviors/feedback.js +279 -194
- package/dist/behaviors/feedback.js.map +1 -1
- package/dist/behaviors/game-core.d.ts +15 -8
- package/dist/behaviors/game-core.js +412 -80
- package/dist/behaviors/game-core.js.map +1 -1
- package/dist/behaviors/game-entity.d.ts +17 -10
- package/dist/behaviors/game-entity.js +544 -237
- package/dist/behaviors/game-entity.js.map +1 -1
- package/dist/behaviors/game-ui.d.ts +16 -8
- package/dist/behaviors/game-ui.js +451 -316
- package/dist/behaviors/game-ui.js.map +1 -1
- package/dist/behaviors/index.d.ts +18 -1
- package/dist/behaviors/index.js +18905 -2140
- package/dist/behaviors/index.js.map +1 -1
- package/dist/behaviors/infrastructure.d.ts +9 -8
- package/dist/behaviors/infrastructure.js +597 -169
- package/dist/behaviors/infrastructure.js.map +1 -1
- package/dist/behaviors/registry.d.ts +11 -11
- package/dist/behaviors/registry.js +18904 -2139
- package/dist/behaviors/registry.js.map +1 -1
- package/dist/behaviors/types.d.ts +19 -2
- package/dist/behaviors/types.js.map +1 -1
- package/dist/behaviors/ui-interaction.d.ts +20 -14
- package/dist/behaviors/ui-interaction.js +928 -518
- package/dist/behaviors/ui-interaction.js.map +1 -1
- package/dist/index.js +18906 -2141
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,660 @@
|
|
|
1
|
+
// behaviors/domain/finance.ts
|
|
2
|
+
var FINANCE_THEME = {
|
|
3
|
+
name: "finance-emerald",
|
|
4
|
+
tokens: {
|
|
5
|
+
colors: {
|
|
6
|
+
primary: "#059669",
|
|
7
|
+
"primary-hover": "#047857",
|
|
8
|
+
"primary-foreground": "#ffffff",
|
|
9
|
+
accent: "#10b981",
|
|
10
|
+
"accent-foreground": "#ffffff",
|
|
11
|
+
success: "#22c55e",
|
|
12
|
+
warning: "#f59e0b",
|
|
13
|
+
error: "#ef4444"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var ledgerMainEffects = [
|
|
18
|
+
["fetch", "LedgerEntry"],
|
|
19
|
+
["render-ui", "main", { type: "stack", direction: "vertical", gap: "lg", children: [
|
|
20
|
+
// Header zone: landmark icon + title + new entry button
|
|
21
|
+
{ type: "stack", direction: "horizontal", justify: "space-between", children: [
|
|
22
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
23
|
+
{ type: "icon", name: "landmark", size: "lg" },
|
|
24
|
+
{ type: "typography", variant: "h2", content: "Ledger" }
|
|
25
|
+
] },
|
|
26
|
+
{ type: "button", label: "New Entry", icon: "plus", variant: "primary", action: "NEW_ENTRY" }
|
|
27
|
+
] },
|
|
28
|
+
{ type: "divider" },
|
|
29
|
+
// Stats zone: debit total, credit total, balance
|
|
30
|
+
{ type: "stack", direction: "horizontal", gap: "md", children: [
|
|
31
|
+
{ type: "stats", label: "Total Debit", icon: "trending-down", entity: "LedgerEntry" },
|
|
32
|
+
{ type: "stats", label: "Total Credit", icon: "trending-up", entity: "LedgerEntry" },
|
|
33
|
+
{ type: "stats", label: "Balance", icon: "wallet", entity: "LedgerEntry" }
|
|
34
|
+
] },
|
|
35
|
+
// Balance trend chart
|
|
36
|
+
{ type: "line-chart", entity: "LedgerEntry" },
|
|
37
|
+
{ type: "divider" },
|
|
38
|
+
// Data zone: ledger entries as card list
|
|
39
|
+
{
|
|
40
|
+
type: "data-list",
|
|
41
|
+
entity: "LedgerEntry",
|
|
42
|
+
variant: "card",
|
|
43
|
+
fields: [
|
|
44
|
+
{ name: "description", label: "Description", icon: "file-text", variant: "h4" },
|
|
45
|
+
{ name: "date", label: "Date", icon: "calendar", variant: "caption", format: "date" },
|
|
46
|
+
{ name: "debit", label: "Debit", icon: "trending-down", variant: "body", format: "currency" },
|
|
47
|
+
{ name: "credit", label: "Credit", icon: "trending-up", variant: "body", format: "currency" },
|
|
48
|
+
{ name: "balance", label: "Balance", icon: "wallet", variant: "body", format: "currency" }
|
|
49
|
+
],
|
|
50
|
+
itemActions: [
|
|
51
|
+
{ label: "View", event: "VIEW", icon: "eye" }
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
] }]
|
|
55
|
+
];
|
|
56
|
+
var transactionMainEffects = [
|
|
57
|
+
["fetch", "Transaction"],
|
|
58
|
+
["render-ui", "main", { type: "stack", direction: "vertical", gap: "lg", children: [
|
|
59
|
+
// Header zone: receipt icon + title + new button + search
|
|
60
|
+
{ type: "stack", direction: "horizontal", justify: "space-between", children: [
|
|
61
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
62
|
+
{ type: "icon", name: "receipt", size: "lg" },
|
|
63
|
+
{ type: "typography", variant: "h2", content: "Transactions" }
|
|
64
|
+
] },
|
|
65
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
66
|
+
{ type: "search-input", placeholder: "Search transactions...", entity: "Transaction" },
|
|
67
|
+
{ type: "button", label: "New", icon: "plus", variant: "primary", action: "CREATE" }
|
|
68
|
+
] }
|
|
69
|
+
] },
|
|
70
|
+
{ type: "divider" },
|
|
71
|
+
// Stats row + line chart
|
|
72
|
+
{ type: "stack", direction: "horizontal", gap: "md", children: [
|
|
73
|
+
{ type: "stats", label: "Total Amount", icon: "dollar-sign", entity: "Transaction" },
|
|
74
|
+
{ type: "stats", label: "Transactions", icon: "hash", entity: "Transaction" },
|
|
75
|
+
{ type: "stats", label: "Avg Amount", icon: "bar-chart-2", entity: "Transaction" }
|
|
76
|
+
] },
|
|
77
|
+
{ type: "line-chart", entity: "Transaction" },
|
|
78
|
+
{ type: "divider" },
|
|
79
|
+
// Data zone: transaction list with badges
|
|
80
|
+
{
|
|
81
|
+
type: "data-list",
|
|
82
|
+
entity: "Transaction",
|
|
83
|
+
variant: "card",
|
|
84
|
+
fields: [
|
|
85
|
+
{ name: "amount", label: "Amount", icon: "dollar-sign", variant: "h4", format: "currency" },
|
|
86
|
+
{ name: "type", label: "Type", icon: "tag", variant: "badge" },
|
|
87
|
+
{ name: "category", label: "Category", icon: "folder", variant: "body" },
|
|
88
|
+
{ name: "date", label: "Date", icon: "calendar", variant: "caption", format: "date" },
|
|
89
|
+
{ name: "status", label: "Status", icon: "circle-dot", variant: "badge" }
|
|
90
|
+
],
|
|
91
|
+
itemActions: [
|
|
92
|
+
{ label: "View", event: "VIEW", icon: "eye" }
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
] }]
|
|
96
|
+
];
|
|
97
|
+
var portfolioMainEffects = [
|
|
98
|
+
["fetch", "Holding"],
|
|
99
|
+
["render-ui", "main", { type: "stack", direction: "vertical", gap: "lg", children: [
|
|
100
|
+
// Header zone: trending-up icon + title
|
|
101
|
+
{ type: "stack", direction: "horizontal", justify: "space-between", children: [
|
|
102
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
103
|
+
{ type: "icon", name: "trending-up", size: "lg" },
|
|
104
|
+
{ type: "typography", variant: "h2", content: "Portfolio" }
|
|
105
|
+
] }
|
|
106
|
+
] },
|
|
107
|
+
{ type: "divider" },
|
|
108
|
+
// Stats zone: total holdings, total value
|
|
109
|
+
{ type: "stack", direction: "horizontal", gap: "md", children: [
|
|
110
|
+
{ type: "stats", label: "Total Holdings", icon: "coins", entity: "Holding" },
|
|
111
|
+
{ type: "stats", label: "Total Value", icon: "dollar-sign", entity: "Holding" }
|
|
112
|
+
] },
|
|
113
|
+
// Performance chart
|
|
114
|
+
{ type: "line-chart", entity: "Holding" },
|
|
115
|
+
{ type: "divider" },
|
|
116
|
+
// Data zone: holdings in a 3-column grid
|
|
117
|
+
{
|
|
118
|
+
type: "data-grid",
|
|
119
|
+
entity: "Holding",
|
|
120
|
+
cols: 3,
|
|
121
|
+
gap: "md",
|
|
122
|
+
fields: [
|
|
123
|
+
{ name: "symbol", label: "Symbol", icon: "coins", variant: "h4" },
|
|
124
|
+
{ name: "shares", label: "Shares", icon: "layers", variant: "body", format: "number" },
|
|
125
|
+
{ name: "purchasePrice", label: "Purchase Price", icon: "credit-card", variant: "body", format: "currency" },
|
|
126
|
+
{ name: "currentPrice", label: "Current Price", icon: "dollar-sign", variant: "body", format: "currency" }
|
|
127
|
+
],
|
|
128
|
+
itemActions: [
|
|
129
|
+
{ label: "View", event: "VIEW", icon: "eye" }
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
] }]
|
|
133
|
+
];
|
|
134
|
+
var LEDGER_BEHAVIOR = {
|
|
135
|
+
name: "std-ledger",
|
|
136
|
+
version: "1.0.0",
|
|
137
|
+
description: "Financial ledger with debit and credit entries",
|
|
138
|
+
orbitals: [
|
|
139
|
+
{
|
|
140
|
+
name: "LedgerOrbital",
|
|
141
|
+
theme: FINANCE_THEME,
|
|
142
|
+
entity: {
|
|
143
|
+
name: "LedgerEntry",
|
|
144
|
+
persistence: "persistent",
|
|
145
|
+
collection: "ledger_entries",
|
|
146
|
+
fields: [
|
|
147
|
+
{ name: "id", type: "string", required: true },
|
|
148
|
+
{ name: "date", type: "string", default: "" },
|
|
149
|
+
{ name: "description", type: "string", default: "" },
|
|
150
|
+
{ name: "debit", type: "number", default: 0 },
|
|
151
|
+
{ name: "credit", type: "number", default: 0 },
|
|
152
|
+
{ name: "balance", type: "number", default: 0 }
|
|
153
|
+
]
|
|
154
|
+
},
|
|
155
|
+
traits: [
|
|
156
|
+
{
|
|
157
|
+
name: "LedgerControl",
|
|
158
|
+
linkedEntity: "LedgerEntry",
|
|
159
|
+
category: "interaction",
|
|
160
|
+
stateMachine: {
|
|
161
|
+
states: [
|
|
162
|
+
{ name: "browsing", isInitial: true },
|
|
163
|
+
{ name: "creating" },
|
|
164
|
+
{ name: "viewing" }
|
|
165
|
+
],
|
|
166
|
+
events: [
|
|
167
|
+
{ key: "INIT", name: "Initialize" },
|
|
168
|
+
{ key: "NEW_ENTRY", name: "New Entry" },
|
|
169
|
+
{ key: "SAVE", name: "Save Entry", payloadSchema: [{ name: "description", type: "string", required: true }, { name: "debit", type: "number", required: true }, { name: "credit", type: "number", required: true }] },
|
|
170
|
+
{ key: "VIEW", name: "View Entry", payloadSchema: [{ name: "id", type: "string", required: true }] },
|
|
171
|
+
{ key: "CLOSE", name: "Close" },
|
|
172
|
+
{ key: "CANCEL", name: "Cancel" }
|
|
173
|
+
],
|
|
174
|
+
transitions: [
|
|
175
|
+
{
|
|
176
|
+
from: "browsing",
|
|
177
|
+
to: "browsing",
|
|
178
|
+
event: "INIT",
|
|
179
|
+
effects: [
|
|
180
|
+
...ledgerMainEffects
|
|
181
|
+
]
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
from: "browsing",
|
|
185
|
+
to: "creating",
|
|
186
|
+
event: "NEW_ENTRY",
|
|
187
|
+
effects: [
|
|
188
|
+
["fetch", "LedgerEntry"],
|
|
189
|
+
["render-ui", "modal", { type: "stack", direction: "vertical", gap: "md", children: [
|
|
190
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
191
|
+
{ type: "icon", name: "plus-circle", size: "md" },
|
|
192
|
+
{ type: "typography", variant: "h3", content: "New Ledger Entry" }
|
|
193
|
+
] },
|
|
194
|
+
{ type: "divider" },
|
|
195
|
+
{
|
|
196
|
+
type: "form-section",
|
|
197
|
+
entity: "LedgerEntry",
|
|
198
|
+
submitEvent: "SAVE",
|
|
199
|
+
cancelEvent: "CANCEL"
|
|
200
|
+
}
|
|
201
|
+
] }]
|
|
202
|
+
]
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
from: "creating",
|
|
206
|
+
to: "browsing",
|
|
207
|
+
event: "SAVE",
|
|
208
|
+
effects: [
|
|
209
|
+
["set", "@entity.description", "@payload.description"],
|
|
210
|
+
["set", "@entity.debit", "@payload.debit"],
|
|
211
|
+
["set", "@entity.credit", "@payload.credit"],
|
|
212
|
+
["render-ui", "modal", null],
|
|
213
|
+
...ledgerMainEffects
|
|
214
|
+
]
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
from: "creating",
|
|
218
|
+
to: "browsing",
|
|
219
|
+
event: "CLOSE",
|
|
220
|
+
effects: [
|
|
221
|
+
["render-ui", "modal", null]
|
|
222
|
+
]
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
from: "creating",
|
|
226
|
+
to: "browsing",
|
|
227
|
+
event: "CANCEL",
|
|
228
|
+
effects: [
|
|
229
|
+
["render-ui", "modal", null]
|
|
230
|
+
]
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
from: "browsing",
|
|
234
|
+
to: "viewing",
|
|
235
|
+
event: "VIEW",
|
|
236
|
+
effects: [
|
|
237
|
+
["fetch", "LedgerEntry"],
|
|
238
|
+
["render-ui", "modal", { type: "stack", direction: "vertical", gap: "md", children: [
|
|
239
|
+
// Header
|
|
240
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
241
|
+
{ type: "icon", name: "landmark", size: "md" },
|
|
242
|
+
{ type: "typography", variant: "h3", content: "Entry Detail" }
|
|
243
|
+
] },
|
|
244
|
+
{ type: "divider" },
|
|
245
|
+
// Balance meter
|
|
246
|
+
{ type: "meter", value: "@entity.balance", label: "Current Balance", icon: "wallet" },
|
|
247
|
+
// Detail fields
|
|
248
|
+
{ type: "stack", direction: "vertical", gap: "sm", children: [
|
|
249
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
250
|
+
{ type: "icon", name: "file-text", size: "sm" },
|
|
251
|
+
{ type: "typography", variant: "label", content: "Description" },
|
|
252
|
+
{ type: "typography", variant: "body", content: "@entity.description" }
|
|
253
|
+
] },
|
|
254
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
255
|
+
{ type: "icon", name: "calendar", size: "sm" },
|
|
256
|
+
{ type: "typography", variant: "label", content: "Date" },
|
|
257
|
+
{ type: "typography", variant: "body", content: "@entity.date" }
|
|
258
|
+
] },
|
|
259
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
260
|
+
{ type: "icon", name: "trending-down", size: "sm" },
|
|
261
|
+
{ type: "typography", variant: "label", content: "Debit" },
|
|
262
|
+
{ type: "typography", variant: "body", content: "@entity.debit" }
|
|
263
|
+
] },
|
|
264
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
265
|
+
{ type: "icon", name: "trending-up", size: "sm" },
|
|
266
|
+
{ type: "typography", variant: "label", content: "Credit" },
|
|
267
|
+
{ type: "typography", variant: "body", content: "@entity.credit" }
|
|
268
|
+
] }
|
|
269
|
+
] },
|
|
270
|
+
{ type: "divider" },
|
|
271
|
+
// Close action
|
|
272
|
+
{ type: "stack", direction: "horizontal", justify: "flex-end", children: [
|
|
273
|
+
{ type: "button", label: "Close", icon: "x", variant: "secondary", action: "CLOSE" }
|
|
274
|
+
] }
|
|
275
|
+
] }]
|
|
276
|
+
]
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
from: "viewing",
|
|
280
|
+
to: "browsing",
|
|
281
|
+
event: "CLOSE",
|
|
282
|
+
effects: [
|
|
283
|
+
["render-ui", "modal", null]
|
|
284
|
+
]
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
from: "viewing",
|
|
288
|
+
to: "browsing",
|
|
289
|
+
event: "CANCEL",
|
|
290
|
+
effects: [
|
|
291
|
+
["render-ui", "modal", null]
|
|
292
|
+
]
|
|
293
|
+
}
|
|
294
|
+
]
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
],
|
|
298
|
+
pages: [
|
|
299
|
+
{
|
|
300
|
+
name: "LedgerPage",
|
|
301
|
+
path: "/ledger",
|
|
302
|
+
isInitial: true,
|
|
303
|
+
traits: [{ ref: "LedgerControl" }]
|
|
304
|
+
}
|
|
305
|
+
]
|
|
306
|
+
}
|
|
307
|
+
]
|
|
308
|
+
};
|
|
309
|
+
var TRANSACTION_BEHAVIOR = {
|
|
310
|
+
name: "std-transaction",
|
|
311
|
+
version: "1.0.0",
|
|
312
|
+
description: "Transaction tracking with categories and status",
|
|
313
|
+
orbitals: [
|
|
314
|
+
{
|
|
315
|
+
name: "TransactionOrbital",
|
|
316
|
+
theme: FINANCE_THEME,
|
|
317
|
+
entity: {
|
|
318
|
+
name: "Transaction",
|
|
319
|
+
persistence: "persistent",
|
|
320
|
+
collection: "transactions",
|
|
321
|
+
fields: [
|
|
322
|
+
{ name: "id", type: "string", required: true },
|
|
323
|
+
{ name: "amount", type: "number", default: 0 },
|
|
324
|
+
{ name: "type", type: "string", default: "expense" },
|
|
325
|
+
{ name: "category", type: "string", default: "" },
|
|
326
|
+
{ name: "date", type: "string", default: "" },
|
|
327
|
+
{ name: "status", type: "string", default: "pending" }
|
|
328
|
+
]
|
|
329
|
+
},
|
|
330
|
+
traits: [
|
|
331
|
+
{
|
|
332
|
+
name: "TransactionControl",
|
|
333
|
+
linkedEntity: "Transaction",
|
|
334
|
+
category: "interaction",
|
|
335
|
+
stateMachine: {
|
|
336
|
+
states: [
|
|
337
|
+
{ name: "browsing", isInitial: true },
|
|
338
|
+
{ name: "viewing" },
|
|
339
|
+
{ name: "creating" }
|
|
340
|
+
],
|
|
341
|
+
events: [
|
|
342
|
+
{ key: "INIT", name: "Initialize" },
|
|
343
|
+
{ key: "VIEW", name: "View Transaction", payloadSchema: [{ name: "id", type: "string", required: true }] },
|
|
344
|
+
{ key: "CREATE", name: "New Transaction" },
|
|
345
|
+
{ key: "SAVE", name: "Save Transaction", payloadSchema: [{ name: "amount", type: "number", required: true }, { name: "category", type: "string", required: true }] },
|
|
346
|
+
{ key: "CLOSE", name: "Close" },
|
|
347
|
+
{ key: "CANCEL", name: "Cancel" }
|
|
348
|
+
],
|
|
349
|
+
transitions: [
|
|
350
|
+
{
|
|
351
|
+
from: "browsing",
|
|
352
|
+
to: "browsing",
|
|
353
|
+
event: "INIT",
|
|
354
|
+
effects: [
|
|
355
|
+
...transactionMainEffects
|
|
356
|
+
]
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
from: "browsing",
|
|
360
|
+
to: "viewing",
|
|
361
|
+
event: "VIEW",
|
|
362
|
+
effects: [
|
|
363
|
+
["fetch", "Transaction"],
|
|
364
|
+
["render-ui", "modal", { type: "stack", direction: "vertical", gap: "md", children: [
|
|
365
|
+
// Header
|
|
366
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
367
|
+
{ type: "icon", name: "receipt", size: "md" },
|
|
368
|
+
{ type: "typography", variant: "h3", content: "Transaction Detail" }
|
|
369
|
+
] },
|
|
370
|
+
{ type: "divider" },
|
|
371
|
+
// Amount + type row
|
|
372
|
+
{ type: "stack", direction: "horizontal", justify: "space-between", children: [
|
|
373
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
374
|
+
{ type: "icon", name: "dollar-sign", size: "md" },
|
|
375
|
+
{ type: "typography", variant: "h4", content: "@entity.amount" }
|
|
376
|
+
] },
|
|
377
|
+
{ type: "badge", content: "@entity.type", icon: "tag" }
|
|
378
|
+
] },
|
|
379
|
+
// Detail fields
|
|
380
|
+
{ type: "stack", direction: "vertical", gap: "sm", children: [
|
|
381
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
382
|
+
{ type: "icon", name: "folder", size: "sm" },
|
|
383
|
+
{ type: "typography", variant: "label", content: "Category" },
|
|
384
|
+
{ type: "typography", variant: "body", content: "@entity.category" }
|
|
385
|
+
] },
|
|
386
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
387
|
+
{ type: "icon", name: "calendar", size: "sm" },
|
|
388
|
+
{ type: "typography", variant: "label", content: "Date" },
|
|
389
|
+
{ type: "typography", variant: "body", content: "@entity.date" }
|
|
390
|
+
] },
|
|
391
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
392
|
+
{ type: "icon", name: "circle-dot", size: "sm" },
|
|
393
|
+
{ type: "typography", variant: "label", content: "Status" },
|
|
394
|
+
{ type: "badge", content: "@entity.status" }
|
|
395
|
+
] }
|
|
396
|
+
] },
|
|
397
|
+
{ type: "divider" },
|
|
398
|
+
// Close action
|
|
399
|
+
{ type: "stack", direction: "horizontal", justify: "flex-end", children: [
|
|
400
|
+
{ type: "button", label: "Close", icon: "x", variant: "secondary", action: "CLOSE" }
|
|
401
|
+
] }
|
|
402
|
+
] }]
|
|
403
|
+
]
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
from: "viewing",
|
|
407
|
+
to: "browsing",
|
|
408
|
+
event: "CLOSE",
|
|
409
|
+
effects: [
|
|
410
|
+
["render-ui", "modal", null]
|
|
411
|
+
]
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
from: "viewing",
|
|
415
|
+
to: "browsing",
|
|
416
|
+
event: "CANCEL",
|
|
417
|
+
effects: [
|
|
418
|
+
["render-ui", "modal", null]
|
|
419
|
+
]
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
from: "browsing",
|
|
423
|
+
to: "creating",
|
|
424
|
+
event: "CREATE",
|
|
425
|
+
effects: [
|
|
426
|
+
["fetch", "Transaction"],
|
|
427
|
+
["render-ui", "modal", { type: "stack", direction: "vertical", gap: "md", children: [
|
|
428
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
429
|
+
{ type: "icon", name: "plus-circle", size: "md" },
|
|
430
|
+
{ type: "typography", variant: "h3", content: "New Transaction" }
|
|
431
|
+
] },
|
|
432
|
+
{ type: "divider" },
|
|
433
|
+
{
|
|
434
|
+
type: "form-section",
|
|
435
|
+
entity: "Transaction",
|
|
436
|
+
submitEvent: "SAVE",
|
|
437
|
+
cancelEvent: "CANCEL"
|
|
438
|
+
}
|
|
439
|
+
] }]
|
|
440
|
+
]
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
from: "creating",
|
|
444
|
+
to: "browsing",
|
|
445
|
+
event: "SAVE",
|
|
446
|
+
effects: [
|
|
447
|
+
["set", "@entity.amount", "@payload.amount"],
|
|
448
|
+
["set", "@entity.category", "@payload.category"],
|
|
449
|
+
["render-ui", "modal", null],
|
|
450
|
+
...transactionMainEffects
|
|
451
|
+
]
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
from: "creating",
|
|
455
|
+
to: "browsing",
|
|
456
|
+
event: "CLOSE",
|
|
457
|
+
effects: [
|
|
458
|
+
["render-ui", "modal", null]
|
|
459
|
+
]
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
from: "creating",
|
|
463
|
+
to: "browsing",
|
|
464
|
+
event: "CANCEL",
|
|
465
|
+
effects: [
|
|
466
|
+
["render-ui", "modal", null]
|
|
467
|
+
]
|
|
468
|
+
}
|
|
469
|
+
]
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
],
|
|
473
|
+
pages: [
|
|
474
|
+
{
|
|
475
|
+
name: "TransactionsPage",
|
|
476
|
+
path: "/transactions",
|
|
477
|
+
isInitial: true,
|
|
478
|
+
traits: [{ ref: "TransactionControl" }]
|
|
479
|
+
}
|
|
480
|
+
]
|
|
481
|
+
}
|
|
482
|
+
]
|
|
483
|
+
};
|
|
484
|
+
var PORTFOLIO_BEHAVIOR = {
|
|
485
|
+
name: "std-portfolio",
|
|
486
|
+
version: "1.0.0",
|
|
487
|
+
description: "Investment portfolio tracking with holdings",
|
|
488
|
+
orbitals: [
|
|
489
|
+
{
|
|
490
|
+
name: "PortfolioOrbital",
|
|
491
|
+
theme: FINANCE_THEME,
|
|
492
|
+
entity: {
|
|
493
|
+
name: "Holding",
|
|
494
|
+
persistence: "persistent",
|
|
495
|
+
collection: "holdings",
|
|
496
|
+
fields: [
|
|
497
|
+
{ name: "id", type: "string", required: true },
|
|
498
|
+
{ name: "symbol", type: "string", default: "" },
|
|
499
|
+
{ name: "shares", type: "number", default: 0 },
|
|
500
|
+
{ name: "purchasePrice", type: "number", default: 0 },
|
|
501
|
+
{ name: "currentPrice", type: "number", default: 0 }
|
|
502
|
+
]
|
|
503
|
+
},
|
|
504
|
+
traits: [
|
|
505
|
+
{
|
|
506
|
+
name: "PortfolioControl",
|
|
507
|
+
linkedEntity: "Holding",
|
|
508
|
+
category: "interaction",
|
|
509
|
+
stateMachine: {
|
|
510
|
+
states: [
|
|
511
|
+
{ name: "browsing", isInitial: true },
|
|
512
|
+
{ name: "viewing" },
|
|
513
|
+
{ name: "trading" }
|
|
514
|
+
],
|
|
515
|
+
events: [
|
|
516
|
+
{ key: "INIT", name: "Initialize" },
|
|
517
|
+
{ key: "VIEW", name: "View Holding", payloadSchema: [{ name: "id", type: "string", required: true }] },
|
|
518
|
+
{ key: "TRADE", name: "Start Trade" },
|
|
519
|
+
{ key: "EXECUTE", name: "Execute Trade", payloadSchema: [{ name: "shares", type: "number", required: true }] },
|
|
520
|
+
{ key: "CLOSE", name: "Close" },
|
|
521
|
+
{ key: "CANCEL", name: "Cancel" }
|
|
522
|
+
],
|
|
523
|
+
transitions: [
|
|
524
|
+
{
|
|
525
|
+
from: "browsing",
|
|
526
|
+
to: "browsing",
|
|
527
|
+
event: "INIT",
|
|
528
|
+
effects: [
|
|
529
|
+
...portfolioMainEffects
|
|
530
|
+
]
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
from: "browsing",
|
|
534
|
+
to: "viewing",
|
|
535
|
+
event: "VIEW",
|
|
536
|
+
effects: [
|
|
537
|
+
["fetch", "Holding"],
|
|
538
|
+
["render-ui", "modal", { type: "stack", direction: "vertical", gap: "md", children: [
|
|
539
|
+
// Header
|
|
540
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
541
|
+
{ type: "icon", name: "coins", size: "md" },
|
|
542
|
+
{ type: "typography", variant: "h3", content: "Holding Detail" }
|
|
543
|
+
] },
|
|
544
|
+
{ type: "divider" },
|
|
545
|
+
// Symbol + shares headline
|
|
546
|
+
{ type: "stack", direction: "horizontal", justify: "space-between", children: [
|
|
547
|
+
{ type: "typography", variant: "h4", content: "@entity.symbol" },
|
|
548
|
+
{ type: "badge", content: "@entity.shares", icon: "layers" }
|
|
549
|
+
] },
|
|
550
|
+
// Price detail fields
|
|
551
|
+
{ type: "stack", direction: "vertical", gap: "sm", children: [
|
|
552
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
553
|
+
{ type: "icon", name: "credit-card", size: "sm" },
|
|
554
|
+
{ type: "typography", variant: "label", content: "Purchase Price" },
|
|
555
|
+
{ type: "typography", variant: "body", content: "@entity.purchasePrice" }
|
|
556
|
+
] },
|
|
557
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
558
|
+
{ type: "icon", name: "dollar-sign", size: "sm" },
|
|
559
|
+
{ type: "typography", variant: "label", content: "Current Price" },
|
|
560
|
+
{ type: "typography", variant: "body", content: "@entity.currentPrice" }
|
|
561
|
+
] }
|
|
562
|
+
] },
|
|
563
|
+
// Gain/loss meter
|
|
564
|
+
{ type: "meter", value: "@entity.currentPrice", label: "Gain / Loss", icon: "bar-chart-2" },
|
|
565
|
+
{ type: "divider" },
|
|
566
|
+
// Actions: trade + close
|
|
567
|
+
{ type: "stack", direction: "horizontal", justify: "flex-end", gap: "sm", children: [
|
|
568
|
+
{ type: "button", label: "Trade", icon: "arrow-right-left", variant: "primary", action: "TRADE" },
|
|
569
|
+
{ type: "button", label: "Close", icon: "x", variant: "secondary", action: "CLOSE" }
|
|
570
|
+
] }
|
|
571
|
+
] }]
|
|
572
|
+
]
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
from: "viewing",
|
|
576
|
+
to: "trading",
|
|
577
|
+
event: "TRADE",
|
|
578
|
+
effects: [
|
|
579
|
+
["fetch", "Holding"],
|
|
580
|
+
["render-ui", "modal", { type: "stack", direction: "vertical", gap: "md", children: [
|
|
581
|
+
{ type: "stack", direction: "horizontal", gap: "sm", children: [
|
|
582
|
+
{ type: "icon", name: "arrow-right-left", size: "md" },
|
|
583
|
+
{ type: "typography", variant: "h3", content: "Execute Trade" }
|
|
584
|
+
] },
|
|
585
|
+
{ type: "divider" },
|
|
586
|
+
{
|
|
587
|
+
type: "form-section",
|
|
588
|
+
entity: "Holding",
|
|
589
|
+
submitEvent: "EXECUTE",
|
|
590
|
+
cancelEvent: "CANCEL"
|
|
591
|
+
}
|
|
592
|
+
] }]
|
|
593
|
+
]
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
from: "trading",
|
|
597
|
+
to: "browsing",
|
|
598
|
+
event: "EXECUTE",
|
|
599
|
+
effects: [
|
|
600
|
+
["set", "@entity.shares", "@payload.shares"],
|
|
601
|
+
["render-ui", "modal", null],
|
|
602
|
+
...portfolioMainEffects
|
|
603
|
+
]
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
from: "viewing",
|
|
607
|
+
to: "browsing",
|
|
608
|
+
event: "CLOSE",
|
|
609
|
+
effects: [
|
|
610
|
+
["render-ui", "modal", null]
|
|
611
|
+
]
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
from: "viewing",
|
|
615
|
+
to: "browsing",
|
|
616
|
+
event: "CANCEL",
|
|
617
|
+
effects: [
|
|
618
|
+
["render-ui", "modal", null]
|
|
619
|
+
]
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
from: "trading",
|
|
623
|
+
to: "browsing",
|
|
624
|
+
event: "CLOSE",
|
|
625
|
+
effects: [
|
|
626
|
+
["render-ui", "modal", null]
|
|
627
|
+
]
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
from: "trading",
|
|
631
|
+
to: "browsing",
|
|
632
|
+
event: "CANCEL",
|
|
633
|
+
effects: [
|
|
634
|
+
["render-ui", "modal", null]
|
|
635
|
+
]
|
|
636
|
+
}
|
|
637
|
+
]
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
],
|
|
641
|
+
pages: [
|
|
642
|
+
{
|
|
643
|
+
name: "PortfolioPage",
|
|
644
|
+
path: "/portfolio",
|
|
645
|
+
isInitial: true,
|
|
646
|
+
traits: [{ ref: "PortfolioControl" }]
|
|
647
|
+
}
|
|
648
|
+
]
|
|
649
|
+
}
|
|
650
|
+
]
|
|
651
|
+
};
|
|
652
|
+
var FINANCE_BEHAVIORS = [
|
|
653
|
+
LEDGER_BEHAVIOR,
|
|
654
|
+
TRANSACTION_BEHAVIOR,
|
|
655
|
+
PORTFOLIO_BEHAVIOR
|
|
656
|
+
];
|
|
657
|
+
|
|
658
|
+
export { FINANCE_BEHAVIORS, LEDGER_BEHAVIOR, PORTFOLIO_BEHAVIOR, TRANSACTION_BEHAVIOR };
|
|
659
|
+
//# sourceMappingURL=finance.js.map
|
|
660
|
+
//# sourceMappingURL=finance.js.map
|