@vc-shell/vc-app-skill 2.0.0-alpha.33 → 2.0.0-alpha.34
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/CHANGELOG.md +78 -54
- package/README.md +42 -12
- package/package.json +4 -4
- package/runtime/VERSION +1 -1
- package/runtime/agents/api-analyzer.md +31 -16
- package/runtime/agents/blade-enhancer.md +15 -9
- package/runtime/agents/details-blade-generator.md +47 -31
- package/runtime/agents/list-blade-generator.md +21 -37
- package/runtime/agents/locales-generator.md +3 -0
- package/runtime/agents/migration-agent.md +18 -7
- package/runtime/agents/module-analyzer.md +2 -0
- package/runtime/agents/module-assembler.md +15 -0
- package/runtime/agents/promote-agent.md +15 -4
- package/runtime/agents/type-checker.md +11 -0
- package/runtime/knowledge/docs/_BUILD_HASH.md +1 -1
- package/runtime/knowledge/docs/core/api/platform.docs.md +30 -30
- package/runtime/knowledge/docs/core/blade-navigation/blade-nav-composables.docs.md +41 -41
- package/runtime/knowledge/docs/core/composables/bladeContext/index.docs.md +12 -10
- package/runtime/knowledge/docs/core/composables/useApiClient/useApiClient.docs.md +11 -14
- package/runtime/knowledge/docs/core/composables/useAppBarMobileButtons/useAppBarMobileButtons.docs.md +35 -35
- package/runtime/knowledge/docs/core/composables/useAppBarWidget/useAppBarWidget.docs.md +35 -35
- package/runtime/knowledge/docs/core/composables/useAppInsights/useAppInsights.docs.md +15 -15
- package/runtime/knowledge/docs/core/composables/useAssets/useAssets.docs.md +21 -18
- package/runtime/knowledge/docs/core/composables/useAssetsManager/useAssetsManager.docs.md +28 -24
- package/runtime/knowledge/docs/core/composables/useAsync/useAsync.docs.md +90 -61
- package/runtime/knowledge/docs/core/composables/useBeforeUnload/useBeforeUnload.docs.md +19 -18
- package/runtime/knowledge/docs/core/composables/useBlade/useBlade.docs.md +89 -68
- package/runtime/knowledge/docs/core/composables/useBladeForm/useBladeForm.docs.md +27 -25
- package/runtime/knowledge/docs/core/composables/useBladeRegistry/useBladeRegistry.docs.md +15 -15
- package/runtime/knowledge/docs/core/composables/useBladeWidgets/index.docs.md +43 -47
- package/runtime/knowledge/docs/core/composables/useBreadcrumbs/useBreadcrumbs.docs.md +11 -11
- package/runtime/knowledge/docs/core/composables/useConnectionStatus/useConnectionStatus.docs.md +27 -15
- package/runtime/knowledge/docs/core/composables/useDashboard/useDashboard.docs.md +30 -30
- package/runtime/knowledge/docs/core/composables/useDynamicProperties/useDynamicProperties.docs.md +34 -36
- package/runtime/knowledge/docs/core/composables/useErrorHandler/useErrorHandler.docs.md +44 -23
- package/runtime/knowledge/docs/core/composables/useFunctions/useFunctions.docs.md +14 -11
- package/runtime/knowledge/docs/core/composables/useKeyboardNavigation/useKeyboardNavigation.docs.md +47 -38
- package/runtime/knowledge/docs/core/composables/useLanguages/useLanguages.docs.md +37 -28
- package/runtime/knowledge/docs/core/composables/useLoading/useLoading.docs.md +23 -17
- package/runtime/knowledge/docs/core/composables/useMenuExpanded/index.docs.md +9 -9
- package/runtime/knowledge/docs/core/composables/useMenuService/useMenuService.docs.md +42 -42
- package/runtime/knowledge/docs/core/composables/useModificationTracker/useModificationTracker.docs.md +22 -12
- package/runtime/knowledge/docs/core/composables/useNotifications/useNotifications.docs.md +33 -41
- package/runtime/knowledge/docs/core/composables/usePermissions/usePermissions.docs.md +16 -16
- package/runtime/knowledge/docs/core/composables/usePlatformLocaleSync/usePlatformLocaleSync.docs.md +28 -0
- package/runtime/knowledge/docs/core/composables/usePopup/usePopup.docs.md +32 -24
- package/runtime/knowledge/docs/core/composables/useResponsive/useResponsive.docs.md +32 -11
- package/runtime/knowledge/docs/core/composables/useSettings/useSettings.docs.md +22 -13
- package/runtime/knowledge/docs/core/composables/useSettingsMenu/useSettingsMenu.docs.md +7 -7
- package/runtime/knowledge/docs/core/composables/useSidebarState/useSidebarState.docs.md +32 -24
- package/runtime/knowledge/docs/core/composables/useSlowNetworkDetection/useSlowNetworkDetection.docs.md +21 -17
- package/runtime/knowledge/docs/core/composables/useTheme/useTheme.docs.md +24 -24
- package/runtime/knowledge/docs/core/composables/useToolbar/useToolbar.docs.md +28 -31
- package/runtime/knowledge/docs/core/composables/useUser/useUser.docs.md +43 -24
- package/runtime/knowledge/docs/core/composables/useUserManagement/useUserManagement.docs.md +68 -48
- package/runtime/knowledge/docs/core/composables/useWebVitals/useWebVitals.docs.md +19 -19
- package/runtime/knowledge/docs/core/composables/useWidgets/useWidgets.docs.md +42 -47
- package/runtime/knowledge/docs/core/directives/autofocus/autofocus.docs.md +10 -4
- package/runtime/knowledge/docs/core/directives/loading/loading.docs.md +35 -20
- package/runtime/knowledge/docs/core/notifications/notifications.docs.md +36 -35
- package/runtime/knowledge/docs/core/plugins/ai-agent/ai-agent.docs.md +38 -38
- package/runtime/knowledge/docs/core/plugins/extension-points/extension-points.docs.md +79 -62
- package/runtime/knowledge/docs/core/plugins/global-error-handler/global-error-handler.docs.md +10 -10
- package/runtime/knowledge/docs/core/plugins/i18n/i18n.docs.md +21 -23
- package/runtime/knowledge/docs/core/plugins/modularity/modularity.docs.md +91 -83
- package/runtime/knowledge/docs/core/plugins/permissions/permissions.docs.md +10 -16
- package/runtime/knowledge/docs/core/plugins/signalR/signalR.docs.md +9 -9
- package/runtime/knowledge/docs/core/plugins/validation/validation.docs.md +65 -22
- package/runtime/knowledge/docs/core/services/services.docs.md +19 -22
- package/runtime/knowledge/docs/core/types/types.docs.md +40 -40
- package/runtime/knowledge/docs/core/utilities/date/date-utilities.docs.md +27 -27
- package/runtime/knowledge/docs/core/utilities/shared-utilities.docs.md +23 -23
- package/runtime/knowledge/docs/core/utilities/thumbnail/thumbnail.docs.md +22 -25
- package/runtime/knowledge/docs/core/utilities/utilities.docs.md +64 -64
- package/runtime/knowledge/docs/injection-keys.docs.md +52 -51
- package/runtime/knowledge/docs/modules/assets-manager/assets-manager.docs.md +9 -9
- package/runtime/knowledge/docs/shell/_internal/popup/common/popup-common.docs.md +23 -43
- package/runtime/knowledge/docs/shell/auth/ChangePasswordPage/change-password-page.docs.md +5 -5
- package/runtime/knowledge/docs/shell/auth/ForgotPasswordPage/forgot-password-page.docs.md +5 -5
- package/runtime/knowledge/docs/shell/auth/InvitePage/invite-page.docs.md +8 -7
- package/runtime/knowledge/docs/shell/auth/LoginPage/login-page.docs.md +7 -7
- package/runtime/knowledge/docs/shell/auth/ResetPasswordPage/reset-password-page.docs.md +8 -7
- package/runtime/knowledge/docs/shell/auth/sign-in/sign-in.docs.md +29 -13
- package/runtime/knowledge/docs/shell/components/change-password/change-password.docs.md +13 -16
- package/runtime/knowledge/docs/shell/components/change-password-button/change-password-button.docs.md +1 -7
- package/runtime/knowledge/docs/shell/components/error-interceptor/error-interceptor.docs.md +5 -5
- package/runtime/knowledge/docs/shell/components/language-selector/language-selector.docs.md +1 -1
- package/runtime/knowledge/docs/shell/components/logout-button/logout-button.docs.md +1 -1
- package/runtime/knowledge/docs/shell/components/notification-template/notification-template.docs.md +17 -9
- package/runtime/knowledge/docs/shell/components/settings-menu/settings-menu.docs.md +11 -17
- package/runtime/knowledge/docs/shell/components/settings-menu-item/settings-menu-item.docs.md +34 -65
- package/runtime/knowledge/docs/shell/components/sidebar/sidebar.docs.md +16 -26
- package/runtime/knowledge/docs/shell/components/theme-selector/theme-selector.docs.md +2 -2
- package/runtime/knowledge/docs/shell/components/user-dropdown-button/user-dropdown-button.docs.md +7 -9
- package/runtime/knowledge/docs/shell/dashboard/dashboard-charts/dashboard-charts.docs.md +30 -40
- package/runtime/knowledge/docs/shell/dashboard/dashboard-widget-card/dashboard-widget-card.docs.md +26 -19
- package/runtime/knowledge/docs/shell/dashboard/draggable-dashboard/draggable-dashboard.docs.md +15 -12
- package/runtime/knowledge/docs/ui/components/atoms/vc-badge/vc-badge.docs.md +15 -26
- package/runtime/knowledge/docs/ui/components/atoms/vc-banner/vc-banner.docs.md +21 -19
- package/runtime/knowledge/docs/ui/components/atoms/vc-button/vc-button.docs.md +83 -67
- package/runtime/knowledge/docs/ui/components/atoms/vc-card/vc-card.docs.md +100 -59
- package/runtime/knowledge/docs/ui/components/atoms/vc-col/vc-col.docs.md +28 -11
- package/runtime/knowledge/docs/ui/components/atoms/vc-container/vc-container.docs.md +20 -17
- package/runtime/knowledge/docs/ui/components/atoms/vc-hint/vc-hint.docs.md +26 -17
- package/runtime/knowledge/docs/ui/components/atoms/vc-icon/vc-icon.docs.md +30 -32
- package/runtime/knowledge/docs/ui/components/atoms/vc-image/vc-image.docs.md +25 -48
- package/runtime/knowledge/docs/ui/components/atoms/vc-label/vc-label.docs.md +29 -24
- package/runtime/knowledge/docs/ui/components/atoms/vc-link/vc-link.docs.md +23 -15
- package/runtime/knowledge/docs/ui/components/atoms/vc-loading/vc-loading.docs.md +22 -13
- package/runtime/knowledge/docs/ui/components/atoms/vc-progress/vc-progress.docs.md +33 -18
- package/runtime/knowledge/docs/ui/components/atoms/vc-row/vc-row.docs.md +56 -15
- package/runtime/knowledge/docs/ui/components/atoms/vc-scrollable-container/vc-scrollable-container.docs.md +28 -15
- package/runtime/knowledge/docs/ui/components/atoms/vc-skeleton/vc-skeleton.docs.md +40 -20
- package/runtime/knowledge/docs/ui/components/atoms/vc-status/vc-status.docs.md +25 -14
- package/runtime/knowledge/docs/ui/components/atoms/vc-status-icon/vc-status-icon.docs.md +40 -14
- package/runtime/knowledge/docs/ui/components/atoms/vc-tooltip/vc-tooltip.docs.md +54 -42
- package/runtime/knowledge/docs/ui/components/atoms/vc-video/vc-video.docs.md +17 -17
- package/runtime/knowledge/docs/ui/components/atoms/vc-widget/vc-widget.docs.md +21 -21
- package/runtime/knowledge/docs/ui/components/molecules/multilanguage-selector/multilanguage-selector.docs.md +23 -10
- package/runtime/knowledge/docs/ui/components/molecules/vc-accordion/vc-accordion.docs.md +55 -44
- package/runtime/knowledge/docs/ui/components/molecules/vc-breadcrumbs/vc-breadcrumbs.docs.md +23 -20
- package/runtime/knowledge/docs/ui/components/molecules/vc-checkbox/vc-checkbox.docs.md +92 -65
- package/runtime/knowledge/docs/ui/components/molecules/vc-checkbox-group/vc-checkbox-group.docs.md +22 -36
- package/runtime/knowledge/docs/ui/components/molecules/vc-color-input/vc-color-input.docs.md +65 -23
- package/runtime/knowledge/docs/ui/components/molecules/vc-date-picker/vc-date-picker.docs.md +52 -73
- package/runtime/knowledge/docs/ui/components/molecules/vc-dropdown/vc-dropdown.docs.md +91 -85
- package/runtime/knowledge/docs/ui/components/molecules/vc-dropdown-panel/vc-dropdown-panel.docs.md +38 -42
- package/runtime/knowledge/docs/ui/components/molecules/vc-editor/vc-editor.docs.md +56 -73
- package/runtime/knowledge/docs/ui/components/molecules/vc-field/vc-field.docs.md +61 -27
- package/runtime/knowledge/docs/ui/components/molecules/vc-file-upload/vc-file-upload.docs.md +42 -50
- package/runtime/knowledge/docs/ui/components/molecules/vc-form/vc-form.docs.md +35 -64
- package/runtime/knowledge/docs/ui/components/molecules/vc-image-tile/vc-image-tile.docs.md +38 -41
- package/runtime/knowledge/docs/ui/components/molecules/vc-input/vc-input.docs.md +109 -131
- package/runtime/knowledge/docs/ui/components/molecules/vc-input-currency/vc-input-currency.docs.md +47 -88
- package/runtime/knowledge/docs/ui/components/molecules/vc-input-dropdown/vc-input-dropdown.docs.md +50 -64
- package/runtime/knowledge/docs/ui/components/molecules/vc-input-group/vc-input-group.docs.md +29 -24
- package/runtime/knowledge/docs/ui/components/molecules/vc-menu/vc-menu.docs.md +32 -28
- package/runtime/knowledge/docs/ui/components/molecules/vc-multivalue/vc-multivalue.docs.md +57 -65
- package/runtime/knowledge/docs/ui/components/molecules/vc-pagination/vc-pagination.docs.md +28 -26
- package/runtime/knowledge/docs/ui/components/molecules/vc-radio-button/vc-radio-button.docs.md +55 -20
- package/runtime/knowledge/docs/ui/components/molecules/vc-radio-group/vc-radio-group.docs.md +21 -35
- package/runtime/knowledge/docs/ui/components/molecules/vc-rating/vc-rating.docs.md +38 -33
- package/runtime/knowledge/docs/ui/components/molecules/vc-select/vc-select.docs.md +72 -83
- package/runtime/knowledge/docs/ui/components/molecules/vc-slider/vc-slider.docs.md +21 -16
- package/runtime/knowledge/docs/ui/components/molecules/vc-switch/vc-switch.docs.md +55 -64
- package/runtime/knowledge/docs/ui/components/molecules/vc-textarea/vc-textarea.docs.md +51 -70
- package/runtime/knowledge/docs/ui/components/molecules/vc-toast/vc-toast.docs.md +58 -57
- package/runtime/knowledge/docs/ui/components/organisms/vc-app/vc-app.docs.md +49 -26
- package/runtime/knowledge/docs/ui/components/organisms/vc-auth-layout/vc-auth-layout.docs.md +82 -28
- package/runtime/knowledge/docs/ui/components/organisms/vc-blade/vc-blade.docs.md +90 -75
- package/runtime/knowledge/docs/ui/components/organisms/vc-data-table/composables/table-composables.docs.md +99 -48
- package/runtime/knowledge/docs/ui/components/organisms/vc-data-table/vc-data-table.docs.md +548 -367
- package/runtime/knowledge/docs/ui/components/organisms/vc-dynamic-property/vc-dynamic-property.docs.md +35 -52
- package/runtime/knowledge/docs/ui/components/organisms/vc-gallery/vc-gallery.docs.md +33 -62
- package/runtime/knowledge/docs/ui/components/organisms/vc-image-upload/vc-image-upload.docs.md +17 -23
- package/runtime/knowledge/docs/ui/components/organisms/vc-popup/vc-popup.docs.md +109 -68
- package/runtime/knowledge/docs/ui/components/organisms/vc-sidebar/vc-sidebar.docs.md +82 -44
- package/runtime/knowledge/docs/ui/composables/ui-composables.docs.md +8 -8
- package/runtime/knowledge/docs/ui/composables/useDataTablePagination.docs.md +164 -0
- package/runtime/knowledge/docs/ui/composables/useDataTableSort.docs.md +34 -26
- package/runtime/knowledge/docs/ui/composables/useTableSelection.docs.md +48 -40
- package/runtime/knowledge/docs/ui/composables/useTableSort.docs.md +30 -17
- package/runtime/knowledge/docs/ui/types/ui-types.docs.md +40 -29
- package/runtime/knowledge/examples/offers-module.md +15 -13
- package/runtime/knowledge/examples/team-module.md +82 -119
- package/runtime/knowledge/examples/videos-module.md +44 -17
- package/runtime/knowledge/index.md +22 -0
- package/runtime/knowledge/migration-prompts/blade-form-migration.md +17 -8
- package/runtime/knowledge/migration-prompts/blade-props-migration.md +1 -2
- package/runtime/knowledge/migration-prompts/datatable-migration.md +801 -0
- package/runtime/knowledge/migration-prompts/icon-migration.md +97 -0
- package/runtime/knowledge/migration-prompts/manual-migration-audit.md +117 -0
- package/runtime/knowledge/migration-prompts/notifications-migration.md +8 -3
- package/runtime/knowledge/migration-prompts/nswag-migration.md +25 -29
- package/runtime/knowledge/migration-prompts/use-assets-migration.md +164 -0
- package/runtime/knowledge/migration-prompts/use-data-table-pagination-migration.md +176 -0
- package/runtime/knowledge/migration-prompts/widgets-migration.md +48 -27
- package/runtime/knowledge/patterns/assets-management.md +20 -20
- package/runtime/knowledge/patterns/blade-navigation.md +7 -14
- package/runtime/knowledge/patterns/blade-widget.md +19 -17
- package/runtime/knowledge/patterns/child-blade-flow.md +19 -7
- package/runtime/knowledge/patterns/composable-details.md +20 -50
- package/runtime/knowledge/patterns/composable-list.md +43 -31
- package/runtime/knowledge/patterns/dashboard-widget.md +14 -16
- package/runtime/knowledge/patterns/datatable-pattern.md +521 -0
- package/runtime/knowledge/patterns/details-blade-pattern.md +78 -116
- package/runtime/knowledge/patterns/extension-points-usage.md +53 -44
- package/runtime/knowledge/patterns/form-validation.md +28 -64
- package/runtime/knowledge/patterns/list-blade-pattern.md +33 -21
- package/runtime/knowledge/patterns/module-structure.md +7 -1
- package/runtime/knowledge/patterns/multilanguage-fields.md +8 -14
- package/runtime/knowledge/patterns/notification-template.md +21 -14
- package/runtime/knowledge/patterns/signalr-notifications.md +30 -32
- package/runtime/knowledge/patterns/toolbar-pattern.md +18 -20
- package/runtime/vc-app.md +241 -62
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Wraps an asynchronous function with reactive `loading` state, reactive `error` state, and automatic error notifications. This is the standard way to handle API calls, saves, deletes, and other async operations throughout VC-Shell applications.
|
|
4
4
|
|
|
5
5
|
When the returned `action` is called, `useAsync` automatically:
|
|
6
|
+
|
|
6
7
|
1. Sets `loading` to `true` and clears any previous `error`
|
|
7
8
|
2. Executes your async function
|
|
8
9
|
3. On failure: parses the error into a `DisplayableError`, stores it in `error`, logs it, optionally shows a toast notification, and re-throws
|
|
@@ -23,7 +24,11 @@ import { OrderClient } from "@api/orders";
|
|
|
23
24
|
|
|
24
25
|
const { getApiClient } = useApiClient(OrderClient);
|
|
25
26
|
|
|
26
|
-
const {
|
|
27
|
+
const {
|
|
28
|
+
loading,
|
|
29
|
+
error,
|
|
30
|
+
action: loadOrder,
|
|
31
|
+
} = useAsync<string>(async (id) => {
|
|
27
32
|
const client = await getApiClient();
|
|
28
33
|
return await client.getOrderById(id);
|
|
29
34
|
});
|
|
@@ -44,41 +49,38 @@ import { useAsync } from "@vc-shell/framework";
|
|
|
44
49
|
|
|
45
50
|
### Parameters
|
|
46
51
|
|
|
47
|
-
| Parameter | Type
|
|
48
|
-
|
|
49
|
-
| `innerAction` | `AsyncAction<Payload, Result>`
|
|
50
|
-
| `options` | `UseAsyncOptions`
|
|
52
|
+
| Parameter | Type | Required | Description |
|
|
53
|
+
| ------------- | ------------------------------ | -------- | ------------------------------- |
|
|
54
|
+
| `innerAction` | `AsyncAction<Payload, Result>` | Yes | The async function to wrap |
|
|
55
|
+
| `options` | `UseAsyncOptions` | No | Configuration for notifications |
|
|
51
56
|
|
|
52
57
|
#### Type Aliases
|
|
53
58
|
|
|
54
59
|
```typescript
|
|
55
|
-
type AsyncAction<Payload = void, Result = void> = (
|
|
56
|
-
payload?: Payload,
|
|
57
|
-
...rest: any[]
|
|
58
|
-
) => Promise<Result>;
|
|
60
|
+
type AsyncAction<Payload = void, Result = void> = (payload?: Payload, ...rest: any[]) => Promise<Result>;
|
|
59
61
|
```
|
|
60
62
|
|
|
61
63
|
#### UseAsyncOptions
|
|
62
64
|
|
|
63
|
-
| Option | Type | Default | Description
|
|
64
|
-
|
|
65
|
-
| `notify` | `boolean` | `true` | Show an error toast notification on failure
|
|
65
|
+
| Option | Type | Default | Description |
|
|
66
|
+
| --------------- | --------- | ------- | -------------------------------------------------------- |
|
|
67
|
+
| `notify` | `boolean` | `true` | Show an error toast notification on failure |
|
|
66
68
|
| `notifyTimeout` | `number` | `8000` | Duration in milliseconds before the toast auto-dismisses |
|
|
67
69
|
|
|
68
70
|
### Returns: `UseAsyncReturn<Payload, Result>`
|
|
69
71
|
|
|
70
|
-
| Property | Type
|
|
71
|
-
|
|
72
|
-
| `loading` | `DeepReadonly<Ref<boolean>>`
|
|
73
|
-
| `error` | `DeepReadonly<Ref<DisplayableError \| null>>` | Reactive error -- set on failure, cleared on next invocation
|
|
74
|
-
| `action` | `AsyncAction<Payload, Result>`
|
|
72
|
+
| Property | Type | Description |
|
|
73
|
+
| --------- | --------------------------------------------- | -------------------------------------------------------------- |
|
|
74
|
+
| `loading` | `DeepReadonly<Ref<boolean>>` | Reactive loading state -- `true` while the action is executing |
|
|
75
|
+
| `error` | `DeepReadonly<Ref<DisplayableError \| null>>` | Reactive error -- set on failure, cleared on next invocation |
|
|
76
|
+
| `action` | `AsyncAction<Payload, Result>` | Wrapped function with the same signature as `innerAction` |
|
|
75
77
|
|
|
76
78
|
### Type Parameters
|
|
77
79
|
|
|
78
|
-
| Name | Default | Description
|
|
79
|
-
|
|
80
|
-
| `Payload` | `void` | Type of the first argument passed to `action`
|
|
81
|
-
| `Result` | `void` | Return type of the async operation
|
|
80
|
+
| Name | Default | Description |
|
|
81
|
+
| --------- | ------- | --------------------------------------------- |
|
|
82
|
+
| `Payload` | `void` | Type of the first argument passed to `action` |
|
|
83
|
+
| `Result` | `void` | Return type of the async operation |
|
|
82
84
|
|
|
83
85
|
---
|
|
84
86
|
|
|
@@ -117,12 +119,10 @@ await loadProduct("prod-42");
|
|
|
117
119
|
When the inner function returns a value, it becomes the resolved value of `action`:
|
|
118
120
|
|
|
119
121
|
```typescript
|
|
120
|
-
const { action: validateSeller } = useAsync<Seller, ValidationFailure[]>(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
},
|
|
125
|
-
);
|
|
122
|
+
const { action: validateSeller } = useAsync<Seller, ValidationFailure[]>(async (seller) => {
|
|
123
|
+
const client = await getApiClient();
|
|
124
|
+
return await client.validateSeller(seller);
|
|
125
|
+
});
|
|
126
126
|
|
|
127
127
|
const failures = await validateSeller(sellerData);
|
|
128
128
|
// failures is typed as ValidationFailure[]
|
|
@@ -134,14 +134,25 @@ The `error` ref contains a parsed `DisplayableError` after a failure. It is auto
|
|
|
134
134
|
|
|
135
135
|
```vue
|
|
136
136
|
<template>
|
|
137
|
-
<VcAlert
|
|
137
|
+
<VcAlert
|
|
138
|
+
v-if="error"
|
|
139
|
+
variant="error"
|
|
140
|
+
>
|
|
138
141
|
{{ error.message }}
|
|
139
142
|
</VcAlert>
|
|
140
|
-
<VcButton
|
|
143
|
+
<VcButton
|
|
144
|
+
:loading="loading"
|
|
145
|
+
@click="save"
|
|
146
|
+
>Save</VcButton
|
|
147
|
+
>
|
|
141
148
|
</template>
|
|
142
149
|
|
|
143
150
|
<script setup lang="ts">
|
|
144
|
-
const {
|
|
151
|
+
const {
|
|
152
|
+
loading,
|
|
153
|
+
error,
|
|
154
|
+
action: save,
|
|
155
|
+
} = useAsync(async () => {
|
|
145
156
|
await saveOrder(order.value);
|
|
146
157
|
});
|
|
147
158
|
</script>
|
|
@@ -153,18 +164,30 @@ By default, `useAsync` shows a toast notification on failure. The notification i
|
|
|
153
164
|
|
|
154
165
|
```typescript
|
|
155
166
|
// Default: shows toast on error
|
|
156
|
-
const { action: save } = useAsync(async () => {
|
|
167
|
+
const { action: save } = useAsync(async () => {
|
|
168
|
+
/* ... */
|
|
169
|
+
});
|
|
157
170
|
|
|
158
171
|
// Explicit: custom timeout
|
|
159
|
-
const { action: save } = useAsync(
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
172
|
+
const { action: save } = useAsync(
|
|
173
|
+
async () => {
|
|
174
|
+
/* ... */
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
notify: true,
|
|
178
|
+
notifyTimeout: 5000,
|
|
179
|
+
},
|
|
180
|
+
);
|
|
163
181
|
|
|
164
182
|
// Silent: no toast notification
|
|
165
|
-
const { action: silentRefresh } = useAsync(
|
|
166
|
-
|
|
167
|
-
|
|
183
|
+
const { action: silentRefresh } = useAsync(
|
|
184
|
+
async () => {
|
|
185
|
+
/* ... */
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
notify: false,
|
|
189
|
+
},
|
|
190
|
+
);
|
|
168
191
|
```
|
|
169
192
|
|
|
170
193
|
### Combining with useApiClient
|
|
@@ -190,9 +213,15 @@ const { action: search, loading } = useAsync<SearchQuery>(async (query) => {
|
|
|
190
213
|
When a blade has multiple async operations, combine their loading states into one:
|
|
191
214
|
|
|
192
215
|
```typescript
|
|
193
|
-
const { action: load, loading: loadLoading } = useAsync<string>(async (id) => {
|
|
194
|
-
|
|
195
|
-
|
|
216
|
+
const { action: load, loading: loadLoading } = useAsync<string>(async (id) => {
|
|
217
|
+
/* ... */
|
|
218
|
+
});
|
|
219
|
+
const { action: save, loading: saveLoading } = useAsync<Product>(async (p) => {
|
|
220
|
+
/* ... */
|
|
221
|
+
});
|
|
222
|
+
const { action: remove, loading: deleteLoading } = useAsync<string>(async (id) => {
|
|
223
|
+
/* ... */
|
|
224
|
+
});
|
|
196
225
|
|
|
197
226
|
// Single reactive boolean: true if ANY operation is running
|
|
198
227
|
const loading = useLoading(loadLoading, saveLoading, deleteLoading);
|
|
@@ -220,19 +249,15 @@ export function useFulfillmentCenter() {
|
|
|
220
249
|
details.value = await client.getFulfillmentCenterById(id!);
|
|
221
250
|
});
|
|
222
251
|
|
|
223
|
-
const { action: save, loading: saveLoading } = useAsync<FulfillmentCenter>(
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
},
|
|
228
|
-
);
|
|
252
|
+
const { action: save, loading: saveLoading } = useAsync<FulfillmentCenter>(async (data) => {
|
|
253
|
+
const client = await getApiClient();
|
|
254
|
+
await client.updateFulfillmentCenter({ fulfillmentCenter: data });
|
|
255
|
+
});
|
|
229
256
|
|
|
230
|
-
const { action: remove, loading: deleteLoading } = useAsync<string>(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
},
|
|
235
|
-
);
|
|
257
|
+
const { action: remove, loading: deleteLoading } = useAsync<string>(async (id) => {
|
|
258
|
+
const client = await getApiClient();
|
|
259
|
+
await client.deleteFulfillmentCenter([id!]);
|
|
260
|
+
});
|
|
236
261
|
|
|
237
262
|
return {
|
|
238
263
|
details,
|
|
@@ -341,14 +366,18 @@ async function onSave() {
|
|
|
341
366
|
```typescript
|
|
342
367
|
// BAD -- creates a new loading ref each call, template never sees it
|
|
343
368
|
async function loadData() {
|
|
344
|
-
const { action, loading } = useAsync(async () => {
|
|
369
|
+
const { action, loading } = useAsync(async () => {
|
|
370
|
+
/* ... */
|
|
371
|
+
});
|
|
345
372
|
await action();
|
|
346
373
|
}
|
|
347
374
|
```
|
|
348
375
|
|
|
349
376
|
```typescript
|
|
350
377
|
// GOOD -- create at setup time, call the action later
|
|
351
|
-
const { action: loadData, loading } = useAsync(async () => {
|
|
378
|
+
const { action: loadData, loading } = useAsync(async () => {
|
|
379
|
+
/* ... */
|
|
380
|
+
});
|
|
352
381
|
|
|
353
382
|
onMounted(() => loadData());
|
|
354
383
|
```
|
|
@@ -381,9 +410,9 @@ const { action: save, loading: saveLoading } = useAsync(async () => saveData());
|
|
|
381
410
|
|
|
382
411
|
## Related
|
|
383
412
|
|
|
384
|
-
| Resource
|
|
385
|
-
|
|
386
|
-
| [`useApiClient`](../useApiClient/)
|
|
387
|
-
| [`useLoading`](../useLoading/)
|
|
388
|
-
| [`useModificationTracker`](../useModificationTracker/)
|
|
389
|
-
| [`notification`](../../../shared/components/notifications/) | The toast notification system used by `useAsync` for error display
|
|
413
|
+
| Resource | Description |
|
|
414
|
+
| ----------------------------------------------------------- | ----------------------------------------------------------------------------------- |
|
|
415
|
+
| [`useApiClient`](../useApiClient/) | Provides typed API client instances to pass into `useAsync` |
|
|
416
|
+
| [`useLoading`](../useLoading/) | Combines multiple `loading` refs into a single boolean |
|
|
417
|
+
| [`useModificationTracker`](../useModificationTracker/) | Tracks dirty state for forms -- often used alongside `useAsync` for save operations |
|
|
418
|
+
| [`notification`](../../../shared/components/notifications/) | The toast notification system used by `useAsync` for error display |
|
|
@@ -12,12 +12,12 @@ Prevents the browser tab from closing when unsaved changes exist by hooking into
|
|
|
12
12
|
|
|
13
13
|
```vue
|
|
14
14
|
<script setup lang="ts">
|
|
15
|
-
import { useBeforeUnload } from
|
|
16
|
-
import { ref, computed } from
|
|
15
|
+
import { useBeforeUnload } from "@vc-shell/framework";
|
|
16
|
+
import { ref, computed } from "vue";
|
|
17
17
|
|
|
18
18
|
// Suppose your blade has a form with a "dirty" flag
|
|
19
|
-
const originalName = ref(
|
|
20
|
-
const currentName = ref(
|
|
19
|
+
const originalName = ref("Widget A");
|
|
20
|
+
const currentName = ref("Widget A");
|
|
21
21
|
|
|
22
22
|
const isModified = computed(() => originalName.value !== currentName.value);
|
|
23
23
|
|
|
@@ -27,7 +27,10 @@ useBeforeUnload(isModified);
|
|
|
27
27
|
|
|
28
28
|
<template>
|
|
29
29
|
<VcBlade title="Edit Widget">
|
|
30
|
-
<VcInput
|
|
30
|
+
<VcInput
|
|
31
|
+
v-model="currentName"
|
|
32
|
+
label="Name"
|
|
33
|
+
/>
|
|
31
34
|
<VcButton @click="save">Save</VcButton>
|
|
32
35
|
</VcBlade>
|
|
33
36
|
</template>
|
|
@@ -37,14 +40,14 @@ useBeforeUnload(isModified);
|
|
|
37
40
|
|
|
38
41
|
### Parameters
|
|
39
42
|
|
|
40
|
-
| Parameter
|
|
41
|
-
|
|
42
|
-
| `modified` | `ComputedRef<boolean>` | Yes
|
|
43
|
+
| Parameter | Type | Required | Description |
|
|
44
|
+
| ---------- | ---------------------- | -------- | ---------------------------------------------------------------------------------- |
|
|
45
|
+
| `modified` | `ComputedRef<boolean>` | Yes | When `true`, the browser shows a leave-confirmation dialog on tab close or refresh |
|
|
43
46
|
|
|
44
47
|
### Returns
|
|
45
48
|
|
|
46
|
-
| Property
|
|
47
|
-
|
|
49
|
+
| Property | Type | Description |
|
|
50
|
+
| ---------- | ---------------------- | ----------------------------------------------------------------------- |
|
|
48
51
|
| `modified` | `ComputedRef<boolean>` | Pass-through of the input ref, useful for chaining or template bindings |
|
|
49
52
|
|
|
50
53
|
## How It Works
|
|
@@ -57,13 +60,13 @@ Because the listener is added in `onBeforeMount` (not `setup`), it avoids attach
|
|
|
57
60
|
|
|
58
61
|
```vue
|
|
59
62
|
<script setup lang="ts">
|
|
60
|
-
import { useBeforeUnload } from
|
|
61
|
-
import { ref, computed, watch } from
|
|
63
|
+
import { useBeforeUnload } from "@vc-shell/framework";
|
|
64
|
+
import { ref, computed, watch } from "vue";
|
|
62
65
|
|
|
63
66
|
const props = defineProps<{ productId: string }>();
|
|
64
67
|
|
|
65
|
-
const product = ref({ name:
|
|
66
|
-
const snapshot = ref({ name:
|
|
68
|
+
const product = ref({ name: "", price: 0 });
|
|
69
|
+
const snapshot = ref({ name: "", price: 0 });
|
|
67
70
|
|
|
68
71
|
// Load data and take a snapshot of the original state
|
|
69
72
|
async function load() {
|
|
@@ -73,9 +76,7 @@ async function load() {
|
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
// Deep-compare current vs. snapshot
|
|
76
|
-
const isModified = computed(() =>
|
|
77
|
-
JSON.stringify(product.value) !== JSON.stringify(snapshot.value),
|
|
78
|
-
);
|
|
79
|
+
const isModified = computed(() => JSON.stringify(product.value) !== JSON.stringify(snapshot.value));
|
|
79
80
|
|
|
80
81
|
// Guard the browser tab
|
|
81
82
|
useBeforeUnload(isModified);
|
|
@@ -84,7 +85,7 @@ useBeforeUnload(isModified);
|
|
|
84
85
|
defineExpose({
|
|
85
86
|
onBeforeClose: () => {
|
|
86
87
|
if (isModified.value) {
|
|
87
|
-
return confirm(
|
|
88
|
+
return confirm("You have unsaved changes. Discard?");
|
|
88
89
|
}
|
|
89
90
|
return true;
|
|
90
91
|
},
|
|
@@ -44,7 +44,9 @@ openBlade({ name: "OrderDetails", param: "order-123" });
|
|
|
44
44
|
import { useBlade } from "@vc-shell/framework";
|
|
45
45
|
|
|
46
46
|
// Typed options — no manual casting needed
|
|
47
|
-
interface BladeOptions {
|
|
47
|
+
interface BladeOptions {
|
|
48
|
+
sellerProduct?: SellerProduct;
|
|
49
|
+
}
|
|
48
50
|
const { param, options, callParent } = useBlade<BladeOptions>();
|
|
49
51
|
|
|
50
52
|
console.log(options.value?.sellerProduct); // typed as SellerProduct | undefined
|
|
@@ -70,7 +72,10 @@ const blade = useBlade();
|
|
|
70
72
|
`useBlade<TOptions>()` accepts an optional generic to type the `options` computed ref:
|
|
71
73
|
|
|
72
74
|
```typescript
|
|
73
|
-
interface MyOptions {
|
|
75
|
+
interface MyOptions {
|
|
76
|
+
productId: string;
|
|
77
|
+
mode: "edit" | "create";
|
|
78
|
+
}
|
|
74
79
|
const { options } = useBlade<MyOptions>();
|
|
75
80
|
// options.value is MyOptions | undefined — no manual casting needed
|
|
76
81
|
```
|
|
@@ -83,68 +88,68 @@ Without the generic, `options.value` defaults to `Record<string, unknown> | unde
|
|
|
83
88
|
|
|
84
89
|
These are reactive `ComputedRef` values that reflect the current blade's state. Accessing them outside blade context throws a runtime error.
|
|
85
90
|
|
|
86
|
-
| Property | Type
|
|
87
|
-
|
|
88
|
-
| `id` | `ComputedRef<string>`
|
|
89
|
-
| `param` | `ComputedRef<string \| undefined>`
|
|
90
|
-
| `options` | `ComputedRef<TOptions \| undefined>`
|
|
91
|
-
| `query` | `ComputedRef<Record<string, string> \| undefined>`
|
|
92
|
-
| `closable` | `ComputedRef<boolean>`
|
|
93
|
-
| `expanded` | `ComputedRef<boolean>`
|
|
94
|
-
| `name` | `ComputedRef<string>`
|
|
91
|
+
| Property | Type | Description |
|
|
92
|
+
| ---------- | -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
93
|
+
| `id` | `ComputedRef<string>` | The current blade's unique ID within the blade stack |
|
|
94
|
+
| `param` | `ComputedRef<string \| undefined>` | Route parameter passed when the blade was opened |
|
|
95
|
+
| `options` | `ComputedRef<TOptions \| undefined>` | Additional options object passed to the blade. Type is `Record<string, unknown>` by default; provide a generic to get a typed ref: `useBlade<MyOptions>()` |
|
|
96
|
+
| `query` | `ComputedRef<Record<string, string> \| undefined>` | URL query parameters scoped to this blade |
|
|
97
|
+
| `closable` | `ComputedRef<boolean>` | `true` when this blade has a parent (i.e., can be closed) |
|
|
98
|
+
| `expanded` | `ComputedRef<boolean>` | `true` when this blade is the active (rightmost) blade |
|
|
99
|
+
| `name` | `ComputedRef<string>` | The blade's registered component name |
|
|
95
100
|
|
|
96
101
|
#### Navigation Methods (work everywhere)
|
|
97
102
|
|
|
98
|
-
| Method | Signature
|
|
99
|
-
|
|
103
|
+
| Method | Signature | Description |
|
|
104
|
+
| ----------- | ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
|
|
100
105
|
| `openBlade` | `(event: BladeOpenEvent & { isWorkspace?: boolean }) => Promise<void>` | Open a blade as a child of the current blade, or as a workspace root if `isWorkspace: true` |
|
|
101
106
|
|
|
102
107
|
#### Action Methods (blade context required)
|
|
103
108
|
|
|
104
|
-
| Method | Signature
|
|
105
|
-
|
|
106
|
-
| `closeSelf` | `() => Promise<boolean>`
|
|
107
|
-
| `closeChildren` | `() => Promise<void>`
|
|
108
|
-
| `replaceWith` | `(event: BladeOpenEvent) => Promise<void>` | Replace the current blade with a different one in the same position (destroys the old blade)
|
|
109
|
+
| Method | Signature | Description |
|
|
110
|
+
| --------------- | ------------------------------------------ | -------------------------------------------------------------------------------------------------------------- |
|
|
111
|
+
| `closeSelf` | `() => Promise<boolean>` | Close the current blade. Returns `true` if a guard prevented closure. Respects `onBeforeClose` guards. |
|
|
112
|
+
| `closeChildren` | `() => Promise<void>` | Close all child blades of the current blade |
|
|
113
|
+
| `replaceWith` | `(event: BladeOpenEvent) => Promise<void>` | Replace the current blade with a different one in the same position (destroys the old blade) |
|
|
109
114
|
| `coverWith` | `(event: BladeOpenEvent) => Promise<void>` | Cover the current blade — hides it and opens a new blade on top. Closing the new blade reveals the hidden one. |
|
|
110
115
|
|
|
111
116
|
#### Communication Methods (blade context required)
|
|
112
117
|
|
|
113
|
-
| Method
|
|
114
|
-
|
|
115
|
-
| `callParent`
|
|
116
|
-
| `exposeToChildren`
|
|
118
|
+
| Method | Signature | Description |
|
|
119
|
+
| ------------------ | -------------------------------------------------------------------- | ---------------------------------------------------------- |
|
|
120
|
+
| `callParent` | `<T = unknown>(method: string, args?: unknown) => Promise<T>` | Invoke a method exposed by the parent blade |
|
|
121
|
+
| `exposeToChildren` | `(methods: Record<string, (...args: unknown[]) => unknown>) => void` | Expose methods that child blades can call via `callParent` |
|
|
117
122
|
|
|
118
123
|
#### Guards and Errors (blade context required)
|
|
119
124
|
|
|
120
|
-
| Method | Signature
|
|
121
|
-
|
|
122
|
-
| `onBeforeClose` | `(guard: () => Promise<boolean>) => void`
|
|
123
|
-
| `setError` | `(error: unknown) => void`
|
|
124
|
-
| `clearError` | `() => void`
|
|
125
|
+
| Method | Signature | Description |
|
|
126
|
+
| --------------- | ----------------------------------------- | ----------------------------------------------- |
|
|
127
|
+
| `onBeforeClose` | `(guard: () => Promise<boolean>) => void` | Register a guard that can prevent blade closure |
|
|
128
|
+
| `setError` | `(error: unknown) => void` | Display an error banner on the blade |
|
|
129
|
+
| `clearError` | `() => void` | Clear the blade error banner |
|
|
125
130
|
|
|
126
131
|
#### Banner Management (blade context required)
|
|
127
132
|
|
|
128
|
-
| Method | Signature | Description
|
|
129
|
-
|
|
130
|
-
| `addBanner` | `(options: Omit<IBladeBanner, "id" \| "_system">) => string` | Add a custom banner to the blade. Returns the banner's unique ID.
|
|
131
|
-
| `removeBanner` | `(id: string) => void` | Remove a specific banner by its ID
|
|
133
|
+
| Method | Signature | Description |
|
|
134
|
+
| -------------- | ------------------------------------------------------------ | ----------------------------------------------------------------------- |
|
|
135
|
+
| `addBanner` | `(options: Omit<IBladeBanner, "id" \| "_system">) => string` | Add a custom banner to the blade. Returns the banner's unique ID. |
|
|
136
|
+
| `removeBanner` | `(id: string) => void` | Remove a specific banner by its ID |
|
|
132
137
|
| `clearBanners` | `() => void` | Remove all custom banners (system error/modified banners are preserved) |
|
|
133
138
|
|
|
134
139
|
#### Lifecycle Hooks (blade context required)
|
|
135
140
|
|
|
136
|
-
| Method | Signature
|
|
137
|
-
|
|
138
|
-
| `onActivated` | `(callback: () => void) => void`
|
|
139
|
-
| `onDeactivated` | `(callback: () => void) => void`
|
|
141
|
+
| Method | Signature | Description |
|
|
142
|
+
| --------------- | -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
|
|
143
|
+
| `onActivated` | `(callback: () => void) => void` | Register a callback fired when this blade becomes the active (rightmost) blade. Only fires on transitions, not on initial mount. |
|
|
144
|
+
| `onDeactivated` | `(callback: () => void) => void` | Register a callback fired when this blade loses active status (another blade opens on top). |
|
|
140
145
|
|
|
141
146
|
> **Note:** Each hook can only be registered once per `useBlade()` call. A second registration logs a warning and is ignored. Use `onMounted` for initial-mount logic — `onActivated` only fires on subsequent activations.
|
|
142
147
|
|
|
143
148
|
#### Deprecated
|
|
144
149
|
|
|
145
|
-
| Method | Signature
|
|
146
|
-
|
|
147
|
-
| `provideBladeData` | `(data: MaybeRef<Record<string, unknown>>) => void`
|
|
150
|
+
| Method | Signature | Description |
|
|
151
|
+
| ------------------ | --------------------------------------------------- | --------------------------------------------------- |
|
|
152
|
+
| `provideBladeData` | `(data: MaybeRef<Record<string, unknown>>) => void` | **Deprecated.** Use `defineBladeContext()` instead. |
|
|
148
153
|
|
|
149
154
|
### BladeOpenEvent
|
|
150
155
|
|
|
@@ -186,8 +191,12 @@ openBlade({
|
|
|
186
191
|
name: "FulfillmentCenterDetails",
|
|
187
192
|
param: centerId,
|
|
188
193
|
options: { mode: "edit" },
|
|
189
|
-
onOpen() {
|
|
190
|
-
|
|
194
|
+
onOpen() {
|
|
195
|
+
selectedItemId.value = centerId;
|
|
196
|
+
},
|
|
197
|
+
onClose() {
|
|
198
|
+
selectedItemId.value = undefined;
|
|
199
|
+
},
|
|
191
200
|
});
|
|
192
201
|
|
|
193
202
|
// Open as workspace (replaces entire blade stack)
|
|
@@ -317,6 +326,7 @@ async function onSave() {
|
|
|
317
326
|
```
|
|
318
327
|
|
|
319
328
|
> **Tip:** `callParent` is generic. If the parent method returns a value, you can type it:
|
|
329
|
+
>
|
|
320
330
|
> ```typescript
|
|
321
331
|
> const count = await callParent<number>("getOffersCount");
|
|
322
332
|
> ```
|
|
@@ -419,11 +429,7 @@ addBanner({
|
|
|
419
429
|
// Banner with custom render function
|
|
420
430
|
addBanner({
|
|
421
431
|
variant: "info",
|
|
422
|
-
render: () => h("span", [
|
|
423
|
-
"Data synced from ",
|
|
424
|
-
h("b", "Warehouse A"),
|
|
425
|
-
" at 14:32",
|
|
426
|
-
]),
|
|
432
|
+
render: () => h("span", ["Data synced from ", h("b", "Warehouse A"), " at 14:32"]),
|
|
427
433
|
});
|
|
428
434
|
|
|
429
435
|
// Remove a specific banner
|
|
@@ -438,14 +444,14 @@ clearBanners();
|
|
|
438
444
|
|
|
439
445
|
The options object passed to `addBanner`:
|
|
440
446
|
|
|
441
|
-
| Property | Type
|
|
442
|
-
|
|
443
|
-
| `variant` | `"danger" \| "warning" \| "info" \| "success"` | required | Color scheme and default icon
|
|
444
|
-
| `message` | `string`
|
|
445
|
-
| `render` | `() => VNode`
|
|
446
|
-
| `dismissible` | `boolean`
|
|
447
|
-
| `icon` | `string`
|
|
448
|
-
| `action` | `{ label: string; handler: () => void }`
|
|
447
|
+
| Property | Type | Default | Description |
|
|
448
|
+
| ------------- | ---------------------------------------------- | -------- | ---------------------------------------------------- |
|
|
449
|
+
| `variant` | `"danger" \| "warning" \| "info" \| "success"` | required | Color scheme and default icon |
|
|
450
|
+
| `message` | `string` | -- | Plain text message |
|
|
451
|
+
| `render` | `() => VNode` | -- | Custom render function (takes priority over message) |
|
|
452
|
+
| `dismissible` | `boolean` | `false` | Show a close button to dismiss the banner |
|
|
453
|
+
| `icon` | `string` | -- | Override the default variant icon (lucide icon name) |
|
|
454
|
+
| `action` | `{ label: string; handler: () => void }` | -- | Action button displayed on the right side |
|
|
449
455
|
|
|
450
456
|
> **Note:** `addBanner` returns a unique string ID. Use it with `removeBanner(id)` to programmatically remove a specific banner. `clearBanners()` removes all custom banners but preserves system banners (error and unsaved changes).
|
|
451
457
|
|
|
@@ -489,6 +495,7 @@ const isLoading = computed(() => ctx.value.loading as boolean);
|
|
|
489
495
|
```
|
|
490
496
|
|
|
491
497
|
> **When to use which:**
|
|
498
|
+
>
|
|
492
499
|
> - `defineBladeContext` / `injectBladeContext` -- for sharing data with **child widgets and nested components** within the same blade's component tree (via provide/inject).
|
|
493
500
|
> - `callParent` / `exposeToChildren` -- for **cross-blade communication** between parent and child blades in the blade stack.
|
|
494
501
|
|
|
@@ -514,8 +521,12 @@ function onRowClick(event: { data: { id?: string } }) {
|
|
|
514
521
|
openBlade({
|
|
515
522
|
name: "ProductDetails",
|
|
516
523
|
param: event.data.id,
|
|
517
|
-
onOpen() {
|
|
518
|
-
|
|
524
|
+
onOpen() {
|
|
525
|
+
selectedItemId.value = event.data.id;
|
|
526
|
+
},
|
|
527
|
+
onClose() {
|
|
528
|
+
selectedItemId.value = undefined;
|
|
529
|
+
},
|
|
519
530
|
});
|
|
520
531
|
}
|
|
521
532
|
|
|
@@ -577,7 +588,9 @@ const item = ref<Order>();
|
|
|
577
588
|
|
|
578
589
|
defineBladeContext({ item }); // share with widgets
|
|
579
590
|
|
|
580
|
-
async function reload() {
|
|
591
|
+
async function reload() {
|
|
592
|
+
await loadOrder(props.param!);
|
|
593
|
+
}
|
|
581
594
|
exposeToChildren({ reload }); // child ShipmentDetails can callParent("reload")
|
|
582
595
|
|
|
583
596
|
function openShipment(id: string) {
|
|
@@ -651,7 +664,9 @@ openBlade({ name: "OrderDetails", param: orderId });
|
|
|
651
664
|
```vue
|
|
652
665
|
<!-- BAD -- child calls callParent("reload") but parent never exposed it -->
|
|
653
666
|
<script setup lang="ts">
|
|
654
|
-
async function reload() {
|
|
667
|
+
async function reload() {
|
|
668
|
+
/* ... */
|
|
669
|
+
}
|
|
655
670
|
// Missing: exposeToChildren({ reload })
|
|
656
671
|
// or: defineExpose({ reload })
|
|
657
672
|
</script>
|
|
@@ -660,7 +675,9 @@ async function reload() { /* ... */ }
|
|
|
660
675
|
```vue
|
|
661
676
|
<!-- GOOD -- explicitly expose methods for children -->
|
|
662
677
|
<script setup lang="ts">
|
|
663
|
-
async function reload() {
|
|
678
|
+
async function reload() {
|
|
679
|
+
/* ... */
|
|
680
|
+
}
|
|
664
681
|
exposeToChildren({ reload });
|
|
665
682
|
// Also expose title for breadcrumbs
|
|
666
683
|
defineExpose({ reload, title });
|
|
@@ -709,12 +726,16 @@ defineBladeContext({ item, loading });
|
|
|
709
726
|
|
|
710
727
|
```typescript
|
|
711
728
|
// BAD -- accesses the ComputedRef object, not the value
|
|
712
|
-
if (param) {
|
|
729
|
+
if (param) {
|
|
730
|
+
/* always truthy -- it's a ComputedRef object */
|
|
731
|
+
}
|
|
713
732
|
```
|
|
714
733
|
|
|
715
734
|
```typescript
|
|
716
735
|
// GOOD -- access the reactive value
|
|
717
|
-
if (param.value) {
|
|
736
|
+
if (param.value) {
|
|
737
|
+
/* correct -- checks the actual string */
|
|
738
|
+
}
|
|
718
739
|
```
|
|
719
740
|
|
|
720
741
|
---
|
|
@@ -730,11 +751,11 @@ if (param.value) { /* correct -- checks the actual string */ }
|
|
|
730
751
|
|
|
731
752
|
## Related
|
|
732
753
|
|
|
733
|
-
| Resource
|
|
734
|
-
|
|
735
|
-
| [`defineBladeContext` / `injectBladeContext`](../useBladeContext.docs.md) | Share reactive blade data with descendant widgets
|
|
736
|
-
| [`useBladeRegistry`](../useBladeRegistry/)
|
|
737
|
-
| [`VcBlade`](../../../ui/components/organisms/vc-blade/)
|
|
738
|
-
| [`VcBladeNavigation`](../../../shared/components/blade-navigation/)
|
|
739
|
-
| [`useToolbar`](../../../shared/composables/useToolbar/)
|
|
740
|
-
| [`usePopup`](../../../shared/composables/usePopup/)
|
|
754
|
+
| Resource | Description |
|
|
755
|
+
| ------------------------------------------------------------------------- | ------------------------------------------------------------ |
|
|
756
|
+
| [`defineBladeContext` / `injectBladeContext`](../useBladeContext.docs.md) | Share reactive blade data with descendant widgets |
|
|
757
|
+
| [`useBladeRegistry`](../useBladeRegistry/) | Look up registered blade components by name |
|
|
758
|
+
| [`VcBlade`](../../../ui/components/organisms/vc-blade/) | The blade UI shell component (header, toolbar, content area) |
|
|
759
|
+
| [`VcBladeNavigation`](../../../shared/components/blade-navigation/) | The container component that renders the blade stack |
|
|
760
|
+
| [`useToolbar`](../../../shared/composables/useToolbar/) | Dynamic toolbar management for blades |
|
|
761
|
+
| [`usePopup`](../../../shared/composables/usePopup/) | Confirmation dialogs, commonly used in close guards |
|