@vc-shell/vc-app-skill 2.10.4-pr406.8ba2b2d → 2.11.0-pr407.4c64f99
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vc-shell/vc-app-skill",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0-pr407.4c64f99",
|
|
4
4
|
"description": "AI coding skill for scaffolding and generating VirtoCommerce Shell applications. Works with Claude Code, OpenCode, Gemini, Codex, Cursor.",
|
|
5
5
|
"bin": "./bin/install.cjs",
|
|
6
6
|
"files": [
|
package/runtime/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.11.0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Synced from framework at commit
|
|
1
|
+
Synced from framework at commit 1bfeef1d5 on 2026-11-05T09:48:16.625Z
|
|
@@ -20,6 +20,8 @@ Headless widgets are defined as plain configuration objects with reactive refs f
|
|
|
20
20
|
|
|
21
21
|
- **`useBladeWidgets`**: Register sidebar widgets (counters, action buttons) for a blade without creating Vue components. Refresh widget data after blade operations (save, delete).
|
|
22
22
|
- **`useWidgetTrigger`**: Inside an external widget component (registered via `registerExternalWidget`) to register `onRefresh` / `onClick` callbacks. The blade can then call `refresh(widgetId)` or `refreshAll()` to trigger them.
|
|
23
|
+
- **Badge color** for a status (quality, completeness): see [Badge color](#badge-color).
|
|
24
|
+
- **Alerts** for things the user should look at (a declined payment, unread messages): see [Alerts](#alerts).
|
|
23
25
|
- When NOT to use `useBladeWidgets`: for widgets that need their own template or complex UI (use `registerExternalWidget` + `useWidgetTrigger` instead).
|
|
24
26
|
|
|
25
27
|
## Basic Usage
|
|
@@ -72,56 +74,166 @@ async function onSave() {
|
|
|
72
74
|
|
|
73
75
|
Inline `useBladeWidgets([...])` is fine for one-off widgets, but extracting becomes essential when widget data comes from API calls (which need their own composables anyway).
|
|
74
76
|
|
|
75
|
-
##
|
|
77
|
+
## Badge color
|
|
76
78
|
|
|
77
|
-
|
|
79
|
+
`badgeVariant` colors the badge to report a status that needs no action, such as a quality score. Unset keeps the default `"primary"`.
|
|
78
80
|
|
|
79
|
-
|
|
|
80
|
-
|
|
|
81
|
-
| `
|
|
81
|
+
| `WidgetBadgeVariant` | Typical meaning |
|
|
82
|
+
| -------------------- | ---------------------------- |
|
|
83
|
+
| `"primary"` | Default, a plain counter |
|
|
84
|
+
| `"success"` | Good state |
|
|
85
|
+
| `"warning"` | Medium state, worth a glance |
|
|
86
|
+
| `"danger"` | Bad state |
|
|
87
|
+
| `"info"` | Neutral information |
|
|
88
|
+
| `"secondary"` | No data, inactive |
|
|
82
89
|
|
|
83
|
-
|
|
90
|
+
Badge color is a status. For something the user should look at, use [alerts](#alerts) instead. A widget can use both: a yellow badge for medium quality and a red dot for a new problem.
|
|
91
|
+
|
|
92
|
+
### Headless widget
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
const score = ref<number>();
|
|
96
|
+
|
|
97
|
+
useBladeWidgets([
|
|
98
|
+
{
|
|
99
|
+
id: "QualityWidget",
|
|
100
|
+
icon: "lucide-gauge",
|
|
101
|
+
title: "PRODUCTS.WIDGETS.QUALITY",
|
|
102
|
+
badge: score,
|
|
103
|
+
badgeVariant: computed(() => (score.value === undefined ? undefined : score.value >= 80 ? "success" : score.value >= 50 ? "warning" : "danger")),
|
|
104
|
+
},
|
|
105
|
+
]);
|
|
106
|
+
```
|
|
84
107
|
|
|
85
|
-
|
|
86
|
-
| ----------------- | -------------------------------------------------------- | -------- | ----------------------------------------- |
|
|
87
|
-
| `id` | `string` | Yes | Unique widget identifier |
|
|
88
|
-
| `icon` | `string` | Yes | Icon name (e.g., `"lucide-tag"`) |
|
|
89
|
-
| `title` | `string` | Yes | i18n key or display title |
|
|
90
|
-
| `badge` | `Ref<number \| string> \| ComputedRef<number \| string>` | No | Badge counter value |
|
|
91
|
-
| `loading` | `Ref<boolean> \| ComputedRef<boolean>` | No | Show loading indicator |
|
|
92
|
-
| `disabled` | `Ref<boolean> \| boolean` | No | Disable the widget |
|
|
93
|
-
| `isVisible` | `ComputedRef<boolean> \| Ref<boolean> \| boolean` | No | Toggle visibility |
|
|
94
|
-
| `onClick` | `() => void` | No | Action when widget is clicked |
|
|
95
|
-
| `onRefresh` | `() => void \| Promise<void>` | No | Called by `refresh(id)` or `refreshAll()` |
|
|
96
|
-
| `alerts` | `Ref<IWidgetAlert[]> \| ComputedRef<IWidgetAlert[]>` | No | Live alerts shown in the widget popup |
|
|
97
|
-
| `alertsComponent` | `Component` | No | Popup content instead of the default rows |
|
|
108
|
+
### External widget
|
|
98
109
|
|
|
99
|
-
|
|
110
|
+
An external widget renders `VcWidget` itself, so it passes `badge-variant` as a prop. The registration does not change.
|
|
111
|
+
|
|
112
|
+
```vue
|
|
113
|
+
<!-- QualityWidget.vue -->
|
|
114
|
+
<script setup lang="ts">
|
|
115
|
+
import { computed, ref } from "vue";
|
|
116
|
+
import { VcWidget, injectBladeContext, useWidgetTrigger } from "@vc-shell/framework";
|
|
100
117
|
|
|
101
|
-
|
|
118
|
+
const ctx = injectBladeContext();
|
|
119
|
+
const productId = computed(() => (ctx.value.item as { id?: string })?.id ?? "");
|
|
120
|
+
const score = ref<number>();
|
|
121
|
+
const variant = computed(() => (score.value === undefined ? undefined : score.value >= 80 ? "success" : score.value >= 50 ? "warning" : "danger"));
|
|
102
122
|
|
|
103
|
-
|
|
104
|
-
|
|
123
|
+
async function load() {
|
|
124
|
+
score.value = await qualityApi.getScore(productId.value);
|
|
125
|
+
}
|
|
105
126
|
|
|
106
|
-
|
|
127
|
+
useWidgetTrigger({ onRefresh: load });
|
|
128
|
+
load();
|
|
129
|
+
</script>
|
|
130
|
+
|
|
131
|
+
<template>
|
|
132
|
+
<VcWidget
|
|
133
|
+
icon="lucide-gauge"
|
|
134
|
+
:title="$t('QUALITY.WIDGET.TITLE')"
|
|
135
|
+
:value="score"
|
|
136
|
+
:badge-variant="variant"
|
|
137
|
+
/>
|
|
138
|
+
</template>
|
|
107
139
|
```
|
|
108
140
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
| `severity` | `"info" \| "warning" \| "error" \| "critical"` | Yes | Drives the dot color and row icon |
|
|
113
|
-
| `text` | `string` | Yes | Already translated |
|
|
114
|
-
| `meta` | `string` | No | Secondary line (time, reason) |
|
|
115
|
-
| `onOpen` | `() => void` | No | Called on row click |
|
|
116
|
-
| `action` | `{ label: string; run: () => void }` | No | Inline action button |
|
|
141
|
+
```ts
|
|
142
|
+
registerExternalWidget({ id: "QualityWidget", component: QualityWidget, targetBlades: ["ProductDetails"] });
|
|
143
|
+
```
|
|
117
144
|
|
|
118
|
-
Alerts
|
|
145
|
+
## Alerts
|
|
119
146
|
|
|
120
|
-
|
|
147
|
+
Alerts tell the user that something in the widget's data needs a look: a declined payment, an address to confirm, unread messages.
|
|
148
|
+
|
|
149
|
+
::storybook id="navigation-vcblade--widgets-with-alerts" height="520"
|
|
150
|
+
|
|
151
|
+
What the user sees:
|
|
152
|
+
|
|
153
|
+
- A dot on the widget icon, colored by the highest severity in the list.
|
|
154
|
+
- Desktop: hovering the widget opens a popup with the alerts. A click on the widget still opens its blade.
|
|
155
|
+
- Touch: the first tap opens the popup with an Open button; a second tap opens the blade.
|
|
156
|
+
- In the overflow menu, widgets with alerts are listed first.
|
|
157
|
+
- An empty list means no dot and no popup.
|
|
158
|
+
|
|
159
|
+
| `severity` | Dot color | Use for |
|
|
160
|
+
| ------------ | --------- | ------------------------------ |
|
|
161
|
+
| `"info"` | Blue | Something new, no problem |
|
|
162
|
+
| `"warning"` | Yellow | Needs attention soon |
|
|
163
|
+
| `"error"` | Red | Something failed |
|
|
164
|
+
| `"critical"` | Red | Blocks work; ranks above error |
|
|
165
|
+
|
|
166
|
+
### IWidgetAlert
|
|
167
|
+
|
|
168
|
+
| Field | Type | Required | Description |
|
|
169
|
+
| ---------- | ----------------------------------------------------- | -------- | ----------------------------------- |
|
|
170
|
+
| `id` | `string` | Yes | Unique within the widget |
|
|
171
|
+
| `severity` | `"info" \| "warning" \| "error" \| "critical"` | Yes | Drives the dot color and row marker |
|
|
172
|
+
| `text` | `string` | Yes | Already translated |
|
|
173
|
+
| `meta` | `string` | No | Secondary line (time, reason) |
|
|
174
|
+
| `onOpen` | `() => void` | No | Called on row click |
|
|
175
|
+
| `action` | `{ label: string; run: () => void \| Promise<void> }` | No | Inline action button on the row |
|
|
176
|
+
|
|
177
|
+
### Alerts are data
|
|
178
|
+
|
|
179
|
+
Compute alerts from what the widget has loaded. They stay exactly as long as the problem does: fix the data and the alert is gone. There is no "mark as seen" and no API to push an alert. When something changes on the server, refetch the data and the alerts follow, together with the badge.
|
|
180
|
+
|
|
181
|
+
### Headless widget
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
const { t } = useI18n();
|
|
185
|
+
const order = ref<Order>();
|
|
186
|
+
|
|
187
|
+
const alerts = computed<IWidgetAlert[]>(() => {
|
|
188
|
+
const list: IWidgetAlert[] = [];
|
|
189
|
+
if (order.value?.paymentStatus === "Declined") {
|
|
190
|
+
list.push({
|
|
191
|
+
id: "payment",
|
|
192
|
+
severity: "error",
|
|
193
|
+
text: t("ORDERS.ALERTS.PAYMENT_DECLINED"),
|
|
194
|
+
meta: formatRelative(order.value.modifiedDate),
|
|
195
|
+
onOpen: () => openBlade({ name: "OrderPayments", param: order.value!.id }),
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
if (order.value && !order.value.shippingAddress?.isConfirmed) {
|
|
199
|
+
list.push({
|
|
200
|
+
id: "address",
|
|
201
|
+
severity: "warning",
|
|
202
|
+
text: t("ORDERS.ALERTS.ADDRESS_UNCONFIRMED"),
|
|
203
|
+
action: { label: t("ORDERS.ALERTS.CONFIRM"), run: () => confirmAddress(order.value!.id) },
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
return list;
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
useBladeWidgets([
|
|
210
|
+
{
|
|
211
|
+
id: "PaymentsWidget",
|
|
212
|
+
icon: "lucide-credit-card",
|
|
213
|
+
title: "ORDERS.WIDGETS.PAYMENTS",
|
|
214
|
+
alerts,
|
|
215
|
+
onClick: () => openBlade({ name: "OrderPayments", param: order.value?.id }),
|
|
216
|
+
},
|
|
217
|
+
]);
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### External widget
|
|
221
|
+
|
|
222
|
+
An external widget passes the same `alerts` through `useWidgetTrigger`. This one counts unread messages and refetches on a push for its entity:
|
|
223
|
+
|
|
224
|
+
```vue
|
|
225
|
+
<!-- MessagesWidget.vue -->
|
|
226
|
+
<script setup lang="ts">
|
|
227
|
+
import { computed, ref } from "vue";
|
|
228
|
+
import { VcWidget, injectBladeContext, useBladeNotifications, useWidgetTrigger, type IWidgetAlert } from "@vc-shell/framework";
|
|
229
|
+
|
|
230
|
+
const ctx = injectBladeContext();
|
|
231
|
+
const entityId = computed(() => (ctx.value.item as { id?: string })?.id ?? "");
|
|
121
232
|
const unread = ref<Message[]>([]);
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
};
|
|
233
|
+
|
|
234
|
+
async function load() {
|
|
235
|
+
unread.value = await messagesApi.searchUnread({ entityId: entityId.value });
|
|
236
|
+
}
|
|
125
237
|
|
|
126
238
|
// A push for this entity: refetch, and the badge and alerts update together
|
|
127
239
|
useBladeNotifications<MessagePush>({
|
|
@@ -130,8 +242,30 @@ useBladeNotifications<MessagePush>({
|
|
|
130
242
|
onMessage: load,
|
|
131
243
|
});
|
|
132
244
|
|
|
133
|
-
const alerts = computed<IWidgetAlert[]>(() =>
|
|
245
|
+
const alerts = computed<IWidgetAlert[]>(() =>
|
|
246
|
+
unread.value.map(
|
|
247
|
+
(m): IWidgetAlert => ({
|
|
248
|
+
id: m.id!,
|
|
249
|
+
severity: "info",
|
|
250
|
+
text: m.content ?? "",
|
|
251
|
+
meta: m.senderName,
|
|
252
|
+
onOpen: openMessenger,
|
|
253
|
+
}),
|
|
254
|
+
),
|
|
255
|
+
);
|
|
256
|
+
|
|
134
257
|
useWidgetTrigger({ onRefresh: load, alerts });
|
|
258
|
+
load();
|
|
259
|
+
</script>
|
|
260
|
+
|
|
261
|
+
<template>
|
|
262
|
+
<VcWidget
|
|
263
|
+
icon="lucide-message-square"
|
|
264
|
+
:title="$t('MESSAGES.WIDGET.TITLE')"
|
|
265
|
+
:value="unread.length"
|
|
266
|
+
@click="openMessenger"
|
|
267
|
+
/>
|
|
268
|
+
</template>
|
|
135
269
|
```
|
|
136
270
|
|
|
137
271
|
Widget alerts are independent from the notification bell: the bell lists notifications, the widget lists what is unresolved in its data.
|
|
@@ -140,6 +274,8 @@ Widget alerts are independent from the notification bell: the bell lists notific
|
|
|
140
274
|
|
|
141
275
|
The popup shows one row per alert by default. To draw it yourself (message previews, an offer card), pass `alertsComponent`. The alerts still decide the dot and whether the popup opens; the component decides what it shows. It receives `IWidgetAlertsComponentProps`: the `alerts` and a `close()` to call after it opens a blade.
|
|
142
276
|
|
|
277
|
+
::storybook id="navigation-vcblade--widgets-custom-alerts-content" height="520"
|
|
278
|
+
|
|
143
279
|
```vue
|
|
144
280
|
<!-- MessagesPreview.vue -->
|
|
145
281
|
<script setup lang="ts">
|
|
@@ -160,12 +296,39 @@ defineProps<IWidgetAlertsComponentProps>();
|
|
|
160
296
|
</template>
|
|
161
297
|
```
|
|
162
298
|
|
|
163
|
-
```
|
|
299
|
+
```ts
|
|
164
300
|
useWidgetTrigger({ onRefresh: load, alerts, alertsComponent: MessagesPreview });
|
|
301
|
+
// or, for a headless widget:
|
|
302
|
+
useBladeWidgets([{ id: "MessagesWidget", icon: "lucide-message-square", title: "MESSAGES.TITLE", alerts, alertsComponent: MessagesPreview }]);
|
|
165
303
|
```
|
|
166
304
|
|
|
167
305
|
Keyboard opening moves focus to the first button, link or input in the component, so put the main action first or make it a real `<button>`.
|
|
168
306
|
|
|
307
|
+
## API
|
|
308
|
+
|
|
309
|
+
### Parameters
|
|
310
|
+
|
|
311
|
+
| Parameter | Type | Required | Description |
|
|
312
|
+
| --------- | ----------------------------- | -------- | ---------------------------- |
|
|
313
|
+
| `widgets` | `HeadlessWidgetDeclaration[]` | Yes | Array of widget declarations |
|
|
314
|
+
|
|
315
|
+
### HeadlessWidgetDeclaration
|
|
316
|
+
|
|
317
|
+
| Field | Type | Required | Description |
|
|
318
|
+
| ----------------- | ------------------------------------------------------------ | -------- | ----------------------------------------- |
|
|
319
|
+
| `id` | `string` | Yes | Unique widget identifier |
|
|
320
|
+
| `icon` | `string` | Yes | Icon name (e.g., `"lucide-tag"`) |
|
|
321
|
+
| `title` | `string` | Yes | i18n key or display title |
|
|
322
|
+
| `badge` | `Ref<number \| string> \| ComputedRef<number \| string>` | No | Badge counter value |
|
|
323
|
+
| `badgeVariant` | `WidgetBadgeVariant \| Ref<WidgetBadgeVariant \| undefined>` | No | Badge color; unset keeps `"primary"` |
|
|
324
|
+
| `loading` | `Ref<boolean> \| ComputedRef<boolean>` | No | Show loading indicator |
|
|
325
|
+
| `disabled` | `Ref<boolean> \| boolean` | No | Disable the widget |
|
|
326
|
+
| `isVisible` | `ComputedRef<boolean> \| Ref<boolean> \| boolean` | No | Toggle visibility |
|
|
327
|
+
| `onClick` | `() => void` | No | Action when widget is clicked |
|
|
328
|
+
| `onRefresh` | `() => void \| Promise<void>` | No | Called by `refresh(id)` or `refreshAll()` |
|
|
329
|
+
| `alerts` | `Ref<IWidgetAlert[]> \| ComputedRef<IWidgetAlert[]>` | No | Live alerts, see [Alerts](#alerts) |
|
|
330
|
+
| `alertsComponent` | `Component` | No | Popup content instead of the default rows |
|
|
331
|
+
|
|
169
332
|
### Returns
|
|
170
333
|
|
|
171
334
|
| Property | Type | Description |
|
|
@@ -196,7 +359,7 @@ useWidgetTrigger({ onRefresh: loadData });
|
|
|
196
359
|
| `onClick` | `() => void` | No | Handler called when widget is clicked in dropdown |
|
|
197
360
|
| `onRefresh` | `() => void \| Promise<void>` | No | Handler called to refresh widget data |
|
|
198
361
|
| `disabled` | `Ref<boolean> \| boolean` | No | Disabled state |
|
|
199
|
-
| `alerts` | `Ref<IWidgetAlert[]>` | No | Live alerts
|
|
362
|
+
| `alerts` | `Ref<IWidgetAlert[]>` | No | Live alerts, see [Alerts](#alerts) |
|
|
200
363
|
| `alertsComponent` | `Component` | No | Popup content instead of the default rows (see above) |
|
|
201
364
|
|
|
202
365
|
### How It Works
|
|
@@ -42,15 +42,16 @@ function openNotifications() {
|
|
|
42
42
|
|
|
43
43
|
## Key Props
|
|
44
44
|
|
|
45
|
-
| Prop
|
|
46
|
-
|
|
|
47
|
-
| `icon`
|
|
48
|
-
| `title`
|
|
49
|
-
| `value`
|
|
50
|
-
| `
|
|
51
|
-
| `
|
|
52
|
-
| `
|
|
53
|
-
| `
|
|
45
|
+
| Prop | Type | Default | Description |
|
|
46
|
+
| -------------- | -------------------------------------------------------------------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
47
|
+
| `icon` | `string` | -- | Icon name (Lucide format, e.g., `"lucide-save"`) |
|
|
48
|
+
| `title` | `string` | -- | Label text below (or beside) the icon |
|
|
49
|
+
| `value` | `string \| number` | -- | Badge count displayed on the icon; numbers above 99 show as "99+" |
|
|
50
|
+
| `badgeVariant` | `"primary" \| "secondary" \| "success" \| "warning" \| "danger" \| "info"` | `"primary"` | Badge color for a status the widget reports |
|
|
51
|
+
| `disabled` | `boolean` | `false` | Prevents clicks and applies muted styling |
|
|
52
|
+
| `isExpanded` | `boolean` | `false` | Expanded visual state |
|
|
53
|
+
| `horizontal` | `boolean` | `false` | Arranges icon and title side by side instead of stacked |
|
|
54
|
+
| `widgetId` | `string` | -- | Sets the `data-widget-id` attribute on the root element. The root also binds `data-widget-name` from `title`; both are used for widget identification/targeting. |
|
|
54
55
|
|
|
55
56
|
## Events
|
|
56
57
|
|
|
@@ -96,6 +97,14 @@ Badge values above 99 are automatically displayed as "99+".
|
|
|
96
97
|
<!-- Badge shows "99+" -->
|
|
97
98
|
```
|
|
98
99
|
|
|
100
|
+
### Badge Color for a Status
|
|
101
|
+
|
|
102
|
+
Use `badgeVariant` when the badge reports a state that needs no action, such as a quality score. For things the user should look at, use alerts (the dot) instead. See [useBladeWidgets](../../../../core/composables/useBladeWidgets/index.docs.md#badge-color) for headless and external widget examples.
|
|
103
|
+
|
|
104
|
+
```vue
|
|
105
|
+
<VcWidget icon="lucide-gauge" title="Quality" :value="64" badge-variant="warning" />
|
|
106
|
+
```
|
|
107
|
+
|
|
99
108
|
## CSS Custom Properties
|
|
100
109
|
|
|
101
110
|
| Variable | Default | Description |
|
|
@@ -113,6 +122,10 @@ Badge values above 99 are automatically displayed as "99+".
|
|
|
113
122
|
|
|
114
123
|
## Alert dot and badge highlight
|
|
115
124
|
|
|
125
|
+
::storybook id="data-display-vcwidget--with-alert-dot" height="200"
|
|
126
|
+
|
|
127
|
+
How to give a widget alerts: [useBladeWidgets → Alerts](../../../../core/composables/useBladeWidgets/index.docs.md#alerts).
|
|
128
|
+
|
|
116
129
|
Inside a blade widget strip, `VcWidget` reads per-widget render state provided by the blade (it renders exactly as before elsewhere):
|
|
117
130
|
|
|
118
131
|
- **Alert dot**: a small dot on the icon (`.vc-widget__alert-dot--danger|--warning|--info`), coloured from the highest alert severity. The dot itself is `aria-hidden`; the widget gets `aria-haspopup="dialog"`, `aria-expanded` for the alert popup, and an `aria-describedby` text such as "2 need attention".
|