clr-lift 21.2.0 → 21.3.0
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/README.md +157 -105
- package/devtools/stub.mjs +5 -0
- package/fesm2022/clr-lift-devtools-development.mjs +57 -0
- package/fesm2022/clr-lift-devtools-development.mjs.map +1 -0
- package/fesm2022/clr-lift.mjs +1509 -20
- package/fesm2022/clr-lift.mjs.map +1 -1
- package/package.json +12 -3
- package/types/clr-lift-devtools-development.d.ts +12 -0
- package/types/clr-lift.d.ts +184 -3
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
**clr-lift** supercharges VMware's **Clarity Design System** with battle-tested enterprise primitives. It fills the gaps
|
|
21
21
|
in standard Clarity by delivering flicker-free datagrid state management, reactive notification systems, async
|
|
22
|
-
multi-step wizards, type-safe form controls, zero-config dark mode, and built-in
|
|
22
|
+
multi-step wizards, type-safe form controls, zero-config dark mode, and built-in localization.
|
|
23
23
|
|
|
24
24
|
```html
|
|
25
25
|
<!-- Enhanced Clarity alert with automatic Error/HttpErrorResponse extraction -->
|
|
@@ -31,19 +31,24 @@ multi-step wizards, type-safe form controls, zero-config dark mode, and built-in
|
|
|
31
31
|
|
|
32
32
|
---
|
|
33
33
|
|
|
34
|
+
This README follows the main branch. Check the
|
|
35
|
+
[release history](https://github.com/wghglory/ngx-lift-workspace/blob/main/CHANGELOG.md) for availability in your
|
|
36
|
+
installed version; source changes under Unreleased are not yet on npm.
|
|
37
|
+
|
|
34
38
|
## ⚡ Highlights
|
|
35
39
|
|
|
36
|
-
- ⚡ **Flicker-Free Datagrids** - `dgState`
|
|
40
|
+
- ⚡ **Flicker-Free Datagrids** - `dgState()` debounces filter changes and suppresses duplicate datagrid states. Pair it
|
|
41
|
+
with `switchMap` to cancel superseded reads.
|
|
37
42
|
- 🔔 **Reactive Feedback Engine** - Signal-backed `cll-alert`, `AlertService`, and global `ToastService` with action
|
|
38
43
|
buttons.
|
|
39
44
|
- 🧙 **Async Timeline Wizard** - `cll-timeline-wizard` with step-level async validation, guard hooks, and reactive
|
|
40
45
|
progress.
|
|
41
|
-
- 📝 **Modern Form Controls** -
|
|
42
|
-
|
|
46
|
+
- 📝 **Modern Form Controls** - `cll-file-reader` reads text through `ControlValueAccessor`; `cll-key-value-inputs`
|
|
47
|
+
edits a caller-owned `FormArray`. Neither uploads files to a server.
|
|
43
48
|
- 🌓 **Zero-Config Theming** - `cll-theme-toggle` seamlessly flips Clarity light/dark themes with instant `localStorage`
|
|
44
49
|
persistence.
|
|
45
|
-
- 🌍 **Built-in
|
|
46
|
-
|
|
50
|
+
- 🌍 **Built-in Localization** - Component dictionaries include English, 简体中文, 繁體中文, Deutsch, Español, Français,
|
|
51
|
+
Italiano, 日本語, 한국어, Nederlands, and Português out of the box.
|
|
47
52
|
- 📦 **100% Standalone & Tree-Shakable** - Built for Angular Signals and `OnPush` change detection.
|
|
48
53
|
|
|
49
54
|
---
|
|
@@ -63,151 +68,196 @@ npm install clr-lift ngx-lift @clr/angular @clr/ui
|
|
|
63
68
|
@import '@clr/ui/clr-ui.min.css';
|
|
64
69
|
```
|
|
65
70
|
|
|
66
|
-
### 3.
|
|
71
|
+
### 3. Enable Clarity animation support
|
|
72
|
+
|
|
73
|
+
Clarity controls such as the datagrid inject Angular's animation builder. Install `@angular/animations` at the same
|
|
74
|
+
version as your app's `@angular/core`, then add its provider to your existing application configuration:
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import {ApplicationConfig} from '@angular/core';
|
|
78
|
+
import {provideAnimations} from '@angular/platform-browser/animations';
|
|
79
|
+
|
|
80
|
+
export const appConfig: ApplicationConfig = {
|
|
81
|
+
providers: [provideAnimations()],
|
|
82
|
+
};
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Pass `appConfig` to `bootstrapApplication(AppComponent, appConfig)` in `main.ts`. Keep your existing Router/HTTP
|
|
86
|
+
providers. Angular 21 marks this API deprecated, but current Clarity controls still require it; follow Clarity's
|
|
87
|
+
compatibility requirements when upgrading.
|
|
88
|
+
|
|
89
|
+
### 4. Use in Your Standalone Component
|
|
90
|
+
|
|
91
|
+
Mount one toast container in the application shell. This standalone root example displays a notification when its button
|
|
92
|
+
is clicked; no backend or application service is required.
|
|
67
93
|
|
|
68
94
|
```typescript
|
|
69
|
-
import {Component, inject
|
|
70
|
-
import {AlertComponent, ToastService, ThemeToggleComponent} from 'clr-lift';
|
|
95
|
+
import {ChangeDetectionStrategy, Component, inject} from '@angular/core';
|
|
96
|
+
import {AlertComponent, ToastContainerComponent, ToastService, ThemeToggleComponent} from 'clr-lift';
|
|
71
97
|
|
|
72
98
|
@Component({
|
|
73
|
-
selector: 'app-
|
|
74
|
-
imports: [AlertComponent, ThemeToggleComponent],
|
|
99
|
+
selector: 'app-root',
|
|
100
|
+
imports: [AlertComponent, ToastContainerComponent, ThemeToggleComponent],
|
|
75
101
|
template: `
|
|
76
|
-
<
|
|
77
|
-
<h2>Cluster Overview</h2>
|
|
102
|
+
<main cds-layout="vertical gap:md">
|
|
78
103
|
<cll-theme-toggle />
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
<main class="p-4">
|
|
82
|
-
@if (errorMessage()) {
|
|
83
|
-
<cll-alert [error]="errorMessage()" [clrAlertClosable]="true" />
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
<button class="btn btn-primary" (click)="notifySuccess()">Dispatch Notification</button>
|
|
104
|
+
<cll-alert alertType="info" content="Ready to build with clr-lift." />
|
|
105
|
+
<button type="button" class="btn btn-primary" (click)="notifySuccess()">Show notification</button>
|
|
87
106
|
</main>
|
|
107
|
+
<cll-toast-container />
|
|
88
108
|
`,
|
|
109
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
89
110
|
})
|
|
90
|
-
export class
|
|
91
|
-
private toastService = inject(ToastService);
|
|
92
|
-
readonly errorMessage = signal<string | null>(null);
|
|
111
|
+
export class AppComponent {
|
|
112
|
+
private readonly toastService = inject(ToastService);
|
|
93
113
|
|
|
94
114
|
notifySuccess(): void {
|
|
95
|
-
this.toastService.success('
|
|
115
|
+
this.toastService.success({title: 'Saved', description: 'Your changes were saved.'});
|
|
96
116
|
}
|
|
97
117
|
}
|
|
98
118
|
```
|
|
99
119
|
|
|
120
|
+
For HTTP errors, bind an `Error` or `HttpErrorResponse` to `[error]`; use `content` for a text message. The animation
|
|
121
|
+
setup above also applies to the datagrid example below.
|
|
122
|
+
|
|
100
123
|
---
|
|
101
124
|
|
|
102
125
|
## 🌟 Flagship Features
|
|
103
126
|
|
|
104
|
-
### 1. `dgState` —
|
|
127
|
+
### 1. `dgState` — Datagrid refresh streams
|
|
105
128
|
|
|
106
|
-
|
|
107
|
-
|
|
129
|
+
`dgState()` is an RxJS operator, not a resource factory. It delays changed filters by 500 ms and suppresses duplicate
|
|
130
|
+
states by default. The application owns requests, loading/error state, and subscription cleanup.
|
|
108
131
|
|
|
109
132
|
```typescript
|
|
110
|
-
import {
|
|
111
|
-
import {
|
|
133
|
+
import {AsyncPipe, JsonPipe} from '@angular/common';
|
|
134
|
+
import {ChangeDetectionStrategy, Component} from '@angular/core';
|
|
135
|
+
import {ClarityModule, ClrDatagridStateInterface} from '@clr/angular';
|
|
112
136
|
import {dgState} from 'clr-lift';
|
|
113
|
-
import {
|
|
137
|
+
import {BehaviorSubject} from 'rxjs';
|
|
114
138
|
|
|
115
139
|
@Component({
|
|
116
|
-
selector: 'app-
|
|
140
|
+
selector: 'app-grid-state',
|
|
141
|
+
imports: [AsyncPipe, JsonPipe, ClarityModule],
|
|
117
142
|
template: `
|
|
118
|
-
<clr-datagrid (clrDgRefresh)="
|
|
119
|
-
<clr-dg-column>Name</clr-dg-column>
|
|
120
|
-
<clr-dg-
|
|
121
|
-
|
|
122
|
-
<clr-dg-row *clrDgItems="let user of usersState.data()?.items">
|
|
123
|
-
<clr-dg-cell>{{ user.name }}</clr-dg-cell>
|
|
124
|
-
<clr-dg-cell>{{ user.email }}</clr-dg-cell>
|
|
125
|
-
</clr-dg-row>
|
|
126
|
-
|
|
127
|
-
<clr-dg-footer>
|
|
128
|
-
<clr-dg-pagination [clrDgTotalItems]="usersState.data()?.total ?? 0" />
|
|
129
|
-
</clr-dg-footer>
|
|
143
|
+
<clr-datagrid (clrDgRefresh)="refresh$.next($event)">
|
|
144
|
+
<clr-dg-column [clrDgField]="'name'">Name</clr-dg-column>
|
|
145
|
+
<clr-dg-row><clr-dg-cell>Ada</clr-dg-cell></clr-dg-row>
|
|
130
146
|
</clr-datagrid>
|
|
147
|
+
<pre>{{ state$ | async | json }}</pre>
|
|
131
148
|
`,
|
|
149
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
132
150
|
})
|
|
133
|
-
export class
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
readonly usersState = dgState((state: ClrDatagridStateInterface) => this.userService.fetchUsers(state), {
|
|
137
|
-
debounceTime: 300,
|
|
138
|
-
});
|
|
151
|
+
export class GridStateComponent {
|
|
152
|
+
readonly refresh$ = new BehaviorSubject<ClrDatagridStateInterface | null>(null);
|
|
153
|
+
readonly state$ = this.refresh$.pipe(dgState());
|
|
139
154
|
}
|
|
140
155
|
```
|
|
141
156
|
|
|
142
|
-
|
|
157
|
+
Click the Name column heading to change sorting and display the emitted grid state. For server requests, follow the
|
|
158
|
+
[complete datagrid example](https://ngx-lift.netlify.app/clr-lift/operators/dgState).
|
|
143
159
|
|
|
144
|
-
|
|
160
|
+
### 2. `cll-timeline-wizard` — Component-based steps
|
|
145
161
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
(finish)="onProvisionComplete($event)"
|
|
150
|
-
(stepChange)="onStepNavigated($event)"
|
|
151
|
-
>
|
|
152
|
-
<ng-template cllStepContent="credentials">
|
|
153
|
-
<app-credentials-step [form]="credentialsForm" />
|
|
154
|
-
</ng-template>
|
|
155
|
-
|
|
156
|
-
<ng-template cllStepContent="network">
|
|
157
|
-
<app-network-step [form]="networkForm" />
|
|
158
|
-
</ng-template>
|
|
159
|
-
</cll-timeline-wizard>
|
|
160
|
-
```
|
|
162
|
+
The wizard takes `[timelineSteps]`, an array of `TimelineStep` configurations. Each step renders a component extending
|
|
163
|
+
`TimelineBaseComponent`; its Reactive Forms group owns validity and its `next$` owns optional async advancement.
|
|
164
|
+
`confirmed` precedes the final async action; `finished` follows success. Persisting from both outputs duplicates work.
|
|
161
165
|
|
|
162
|
-
|
|
166
|
+
Start with the [complete wizard demo](https://ngx-lift.netlify.app/clr-lift/components/timeline-wizard), including step
|
|
167
|
+
classes, required initial state, form setup and failure recovery. Content templates and `cllStepContent` are not APIs.
|
|
163
168
|
|
|
164
|
-
|
|
169
|
+
### 3. `cll-file-reader` — Read text into a form
|
|
165
170
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
+
Select a PEM/text file to read its text into the control. `maxSize` is in MiB; `acceptFiles` is a file-chooser hint. Set
|
|
172
|
+
`encoded` for base64 text, with UTF-8 by default or explicit `textEncoding="latin1"` for legacy byte strings. The
|
|
173
|
+
component does not upload files, return DataURLs/ArrayBuffers, or provide drag-and-drop handling.
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
import {ChangeDetectionStrategy, Component} from '@angular/core';
|
|
177
|
+
import {FormControl, ReactiveFormsModule} from '@angular/forms';
|
|
178
|
+
import {FileReaderComponent} from 'clr-lift';
|
|
179
|
+
|
|
180
|
+
@Component({
|
|
181
|
+
selector: 'app-certificate-import',
|
|
182
|
+
imports: [ReactiveFormsModule, FileReaderComponent],
|
|
183
|
+
template: `
|
|
184
|
+
<label for="certificate-file">Certificate file</label>
|
|
185
|
+
<cll-file-reader controlId="certificate-file" [formControl]="content" acceptFiles=".pem,.crt" [maxSize]="5" />
|
|
186
|
+
<pre>{{ content.value }}</pre>
|
|
187
|
+
`,
|
|
188
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
189
|
+
})
|
|
190
|
+
export class CertificateImportComponent {
|
|
191
|
+
readonly content = new FormControl('', {nonNullable: true});
|
|
192
|
+
}
|
|
171
193
|
```
|
|
172
194
|
|
|
173
195
|
---
|
|
174
196
|
|
|
175
197
|
## 🧩 Component & Operator Quick Reference
|
|
176
198
|
|
|
177
|
-
| Category | Export | Selector / API | Description
|
|
178
|
-
| :----------------- | :----------------------------- | :------------------------- |
|
|
179
|
-
| **Datagrid** | `dgState` | Operator / Utility |
|
|
180
|
-
| **Feedback** | `AlertComponent` | `cll-alert` | Intelligent alert container with auto-unwrapping for `Error` and `HttpErrorResponse`.
|
|
181
|
-
| | `AlertContainerComponent` | `cll-alert-container` | Multi-alert reactive stack controlled declaratively by `AlertService`.
|
|
182
|
-
| | `ToastService` | Injectable Service | Global toast dispatcher supporting `success`, `error`, `warning`, `info`.
|
|
183
|
-
| | `ToastContainerComponent` | `cll-toast-container` | Root toast overlay host with positioning and auto-dismiss timing.
|
|
184
|
-
| | `SpinnerComponent` | `cll-spinner` | Center-aligned, sized (`sm`, `md`, `lg`), accessible loading spinner.
|
|
185
|
-
| | `StatusIndicatorComponent` | `cll-status-indicator` | Semantic operational state badges (`success`, `warning`, `error`, `pending`).
|
|
186
|
-
| **Navigation** | `TimelineWizardComponent` | `cll-timeline-wizard` | Multi-step asynchronous wizard with timeline navigation and async step hooks.
|
|
187
|
-
| | `PageContainerComponent` | `cll-page-container` | Standardized header, breadcrumb, action bar, and content responsive shell.
|
|
188
|
-
| **Forms** | `FileReaderComponent` | `cll-file-reader` |
|
|
189
|
-
| | `KeyValueInputsComponent` | `cll-key-value-inputs` |
|
|
190
|
-
| **Theming & i18n** | `ThemeToggleComponent` | `cll-theme-toggle` | Light/dark theme switch with Clarity token synchronization & persistence.
|
|
191
|
-
| | `TranslationService` | Injectable Service |
|
|
192
|
-
| | `TranslatePipe` | `translate` | Reactive pipe for localized component labels and messages.
|
|
193
|
-
| **Overlays** | `CalloutComponent` | `cll-callout` | Lightweight contextual notice box with subtle borders.
|
|
194
|
-
| | `CertificateSignpostComponent` | `cll-certificate-signpost` | Interactive X.509 certificate inspector showing SAN, expiry, and issuer details.
|
|
195
|
-
| | `TooltipDirective` | `[cllTooltip]` | Dynamic declarative popover tooltip.
|
|
199
|
+
| Category | Export | Selector / API | Description |
|
|
200
|
+
| :----------------- | :----------------------------- | :------------------------- | :-------------------------------------------------------------------------------------------------- |
|
|
201
|
+
| **Datagrid** | `dgState` | Operator / Utility | RxJS state operator; debounces filters and optionally suppresses duplicates. |
|
|
202
|
+
| **Feedback** | `AlertComponent` | `cll-alert` | Intelligent alert container with auto-unwrapping for `Error` and `HttpErrorResponse`. |
|
|
203
|
+
| | `AlertContainerComponent` | `cll-alert-container` | Multi-alert reactive stack controlled declaratively by `AlertService`. |
|
|
204
|
+
| | `ToastService` | Injectable Service | Global toast dispatcher supporting `success`, `error`, `warning`, `info`. |
|
|
205
|
+
| | `ToastContainerComponent` | `cll-toast-container` | Root toast overlay host with positioning and auto-dismiss timing. |
|
|
206
|
+
| | `SpinnerComponent` | `cll-spinner` | Center-aligned, sized (`sm`, `md`, `lg`), accessible loading spinner. |
|
|
207
|
+
| | `StatusIndicatorComponent` | `cll-status-indicator` | Semantic operational state badges (`success`, `warning`, `error`, `pending`). |
|
|
208
|
+
| **Navigation** | `TimelineWizardComponent` | `cll-timeline-wizard` | Multi-step asynchronous wizard with timeline navigation and async step hooks. |
|
|
209
|
+
| | `PageContainerComponent` | `cll-page-container` | Standardized header, breadcrumb, action bar, and content responsive shell. |
|
|
210
|
+
| **Forms** | `FileReaderComponent` | `cll-file-reader` | Text/base64 string CVA with size validation and read cancellation. |
|
|
211
|
+
| | `KeyValueInputsComponent` | `cll-key-value-inputs` | Caller-owned FormArray editor with duplicate key validation; not a CVA. |
|
|
212
|
+
| **Theming & i18n** | `ThemeToggleComponent` | `cll-theme-toggle` | Light/dark theme switch with Clarity token synchronization & persistence. |
|
|
213
|
+
| | `TranslationService` | Injectable Service | Runtime language selection, dictionary registration and fallback. |
|
|
214
|
+
| | `TranslatePipe` | `translate` | Reactive pipe for localized component labels and messages. |
|
|
215
|
+
| **Overlays** | `CalloutComponent` | `cll-callout` | Lightweight contextual notice box with subtle borders. |
|
|
216
|
+
| | `CertificateSignpostComponent` | `cll-certificate-signpost` | Interactive X.509 certificate inspector showing SAN, expiry, and issuer details. |
|
|
217
|
+
| | `TooltipDirective` | `[cllTooltip]` | Dynamic declarative popover tooltip. |
|
|
218
|
+
| **Development** | `QueryDevtoolsComponent` | `cll-query-devtools` | Resizable query panel with data/error inspection, row actions and a development-only root provider. |
|
|
219
|
+
|
|
220
|
+
**Unreleased on main:** the inspector and `clr-lift/devtools` entry point below are not in clr-lift 21.2.0. Use a
|
|
221
|
+
release containing them before copying this setup. Register once in `app.config.ts`:
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
import {ApplicationConfig} from '@angular/core';
|
|
225
|
+
import {provideQueryDevtools} from 'clr-lift/devtools';
|
|
226
|
+
|
|
227
|
+
export const appConfig: ApplicationConfig = {
|
|
228
|
+
providers: [provideQueryDevtools()],
|
|
229
|
+
};
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
The development launcher opens a resizable, nonmodal bottom panel. Search/filter/sort/paginate queries, inspect data,
|
|
233
|
+
errors and tags, copy keys, and explicitly refetch one query. Data previews are bounded, expandable and read-only. With
|
|
234
|
+
ngx-lift 21.3, inspection is available; Refetch controls require a client exposing `refetchQuery`. Automatic snapshots
|
|
235
|
+
run only while open and unpaused. `provideQueryClient()` is needed only to customize client settings. The package's
|
|
236
|
+
production condition resolves to a no-op and excludes the inspector implementation.
|
|
237
|
+
|
|
238
|
+
For scoped clients or inline placement, import `QueryDevtoolsComponent` and use
|
|
239
|
+
`<cll-query-devtools [client]="scopedQueryClient" />`. The caller retains client ownership. `launcher="floating"`
|
|
240
|
+
selects the icon launcher. `[enabled]="true"` deliberately enables a direct component import outside development, as in
|
|
241
|
+
the documentation preview; that opt-in bypasses the provider's production exclusion. See the
|
|
242
|
+
[design spec](https://github.com/wghglory/ngx-lift-workspace/blob/main/docs/design/clr-lift/query-devtools-design-spec.md).
|
|
196
243
|
|
|
197
244
|
---
|
|
198
245
|
|
|
199
246
|
## 🌍 Built-in Localization
|
|
200
247
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
| **한국어 (`ko`)** | **Nederlands (`nl`)** | **Português (`pt`, `pt-BR`)** | **Русский (`ru`)** |
|
|
248
|
+
Library dictionaries cover English, Simplified/Traditional Chinese, German, Spanish, French, Italian, Japanese, Korean,
|
|
249
|
+
Dutch, Portuguese and Russian, with regional fallback. The demo maintains eleven language dictionaries; its locale
|
|
250
|
+
inventory differs from the library dictionaries. Key/placeholder checks establish dictionary completeness; independent
|
|
251
|
+
native-speaker acceptance remains separate. Applications own translations for their content and can register additional
|
|
252
|
+
dictionaries.
|
|
207
253
|
|
|
208
254
|
Switch language on the fly via `TranslationService`:
|
|
209
255
|
|
|
210
256
|
```typescript
|
|
257
|
+
// Inside a component/service injection context.
|
|
258
|
+
import {inject} from '@angular/core';
|
|
259
|
+
import {TranslationService} from 'clr-lift';
|
|
260
|
+
|
|
211
261
|
const translationService = inject(TranslationService);
|
|
212
262
|
|
|
213
263
|
// Change locale at runtime - all clr-lift components react immediately!
|
|
@@ -218,16 +268,17 @@ translationService.setLanguage('zh-CN');
|
|
|
218
268
|
|
|
219
269
|
## 🧪 Testing
|
|
220
270
|
|
|
221
|
-
`clr-lift
|
|
271
|
+
When testing components that consume `clr-lift`, import the component under test. For example, a standalone alert needs
|
|
272
|
+
no application-specific provider:
|
|
222
273
|
|
|
223
274
|
```typescript
|
|
224
275
|
import {TestBed} from '@angular/core/testing';
|
|
225
|
-
import {
|
|
276
|
+
import {beforeEach} from 'vitest';
|
|
277
|
+
import {AlertComponent} from 'clr-lift';
|
|
226
278
|
|
|
227
279
|
beforeEach(async () => {
|
|
228
280
|
await TestBed.configureTestingModule({
|
|
229
|
-
imports: [
|
|
230
|
-
providers: [TranslationService],
|
|
281
|
+
imports: [AlertComponent],
|
|
231
282
|
}).compileComponents();
|
|
232
283
|
});
|
|
233
284
|
```
|
|
@@ -240,5 +291,6 @@ MIT © [Guanghui Wang](https://github.com/wghglory)
|
|
|
240
291
|
|
|
241
292
|
## Lifecycle and production contracts
|
|
242
293
|
|
|
243
|
-
See
|
|
244
|
-
|
|
294
|
+
See
|
|
295
|
+
[service scoping, clocks, localization and query diagnostics](https://github.com/wghglory/ngx-lift-workspace/blob/main/docs/guides/demo-and-library-integration.md)
|
|
296
|
+
for ownership and loading contracts.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { isPlatformBrowser, DOCUMENT } from '@angular/common';
|
|
2
|
+
import { InjectionToken, makeEnvironmentProviders, provideEnvironmentInitializer, isDevMode, inject, PLATFORM_ID, EnvironmentInjector, ApplicationRef, DestroyRef, afterNextRender, createComponent } from '@angular/core';
|
|
3
|
+
import { QueryDevtoolsComponent } from 'clr-lift';
|
|
4
|
+
|
|
5
|
+
const installation = new InjectionToken('query devtools installation', {
|
|
6
|
+
providedIn: 'root',
|
|
7
|
+
factory: () => ({ installed: false }),
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* Install one floating query inspector at application root. The package's production condition supplies a no-op.
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const appConfig: ApplicationConfig = {providers: [provideQueryDevtools()]};
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
function provideQueryDevtools() {
|
|
17
|
+
return makeEnvironmentProviders([
|
|
18
|
+
provideEnvironmentInitializer(() => {
|
|
19
|
+
if (!isDevMode() || !isPlatformBrowser(inject(PLATFORM_ID)))
|
|
20
|
+
return;
|
|
21
|
+
const state = inject(installation);
|
|
22
|
+
if (state.installed)
|
|
23
|
+
return;
|
|
24
|
+
state.installed = true;
|
|
25
|
+
const document = inject(DOCUMENT);
|
|
26
|
+
const environmentInjector = inject(EnvironmentInjector);
|
|
27
|
+
const applicationRef = inject(ApplicationRef);
|
|
28
|
+
const destroyRef = inject(DestroyRef);
|
|
29
|
+
let component;
|
|
30
|
+
let host;
|
|
31
|
+
const render = afterNextRender(() => {
|
|
32
|
+
host = document.createElement('cll-query-devtools-root');
|
|
33
|
+
component = createComponent(QueryDevtoolsComponent, { environmentInjector, hostElement: host });
|
|
34
|
+
component.setInput('launcher', 'floating');
|
|
35
|
+
document.body.append(host);
|
|
36
|
+
applicationRef.attachView(component.hostView);
|
|
37
|
+
component.changeDetectorRef.detectChanges();
|
|
38
|
+
}, { injector: environmentInjector });
|
|
39
|
+
destroyRef.onDestroy(() => {
|
|
40
|
+
render.destroy();
|
|
41
|
+
if (component) {
|
|
42
|
+
applicationRef.detachView(component.hostView);
|
|
43
|
+
component.destroy();
|
|
44
|
+
}
|
|
45
|
+
host?.remove();
|
|
46
|
+
state.installed = false;
|
|
47
|
+
});
|
|
48
|
+
}),
|
|
49
|
+
]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Generated bundle index. Do not edit.
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
export { provideQueryDevtools };
|
|
57
|
+
//# sourceMappingURL=clr-lift-devtools-development.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clr-lift-devtools-development.mjs","sources":["../../../../libs/clr-lift/devtools/development/index.ts","../../../../libs/clr-lift/devtools/development/clr-lift-devtools-development.ts"],"sourcesContent":["import {DOCUMENT, isPlatformBrowser} from '@angular/common';\nimport {\n afterNextRender,\n ApplicationRef,\n createComponent,\n ComponentRef,\n DestroyRef,\n EnvironmentInjector,\n EnvironmentProviders,\n inject,\n InjectionToken,\n isDevMode,\n makeEnvironmentProviders,\n PLATFORM_ID,\n provideEnvironmentInitializer,\n} from '@angular/core';\nimport {QueryDevtoolsComponent} from 'clr-lift';\n\nconst installation = new InjectionToken('query devtools installation', {\n providedIn: 'root',\n factory: () => ({installed: false}),\n});\n\n/**\n * Install one floating query inspector at application root. The package's production condition supplies a no-op.\n * @example\n * ```typescript\n * const appConfig: ApplicationConfig = {providers: [provideQueryDevtools()]};\n * ```\n */\nexport function provideQueryDevtools(): EnvironmentProviders {\n return makeEnvironmentProviders([\n provideEnvironmentInitializer(() => {\n if (!isDevMode() || !isPlatformBrowser(inject(PLATFORM_ID))) return;\n const state = inject(installation);\n if (state.installed) return;\n state.installed = true;\n const document = inject(DOCUMENT);\n const environmentInjector = inject(EnvironmentInjector);\n const applicationRef = inject(ApplicationRef);\n const destroyRef = inject(DestroyRef);\n let component: ComponentRef<QueryDevtoolsComponent> | undefined;\n let host: HTMLElement | undefined;\n const render = afterNextRender(\n () => {\n host = document.createElement('cll-query-devtools-root');\n component = createComponent(QueryDevtoolsComponent, {environmentInjector, hostElement: host});\n component.setInput('launcher', 'floating');\n document.body.append(host);\n applicationRef.attachView(component.hostView);\n component.changeDetectorRef.detectChanges();\n },\n {injector: environmentInjector},\n );\n destroyRef.onDestroy(() => {\n render.destroy();\n if (component) {\n applicationRef.detachView(component.hostView);\n component.destroy();\n }\n host?.remove();\n state.installed = false;\n });\n }),\n ]);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAkBA,MAAM,YAAY,GAAG,IAAI,cAAc,CAAC,6BAA6B,EAAE;AACrE,IAAA,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,OAAO,EAAC,SAAS,EAAE,KAAK,EAAC,CAAC;AACpC,CAAA,CAAC;AAEF;;;;;;AAMG;SACa,oBAAoB,GAAA;AAClC,IAAA,OAAO,wBAAwB,CAAC;QAC9B,6BAA6B,CAAC,MAAK;YACjC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;gBAAE;AAC7D,YAAA,MAAM,KAAK,GAAG,MAAM,CAAC,YAAY,CAAC;YAClC,IAAI,KAAK,CAAC,SAAS;gBAAE;AACrB,YAAA,KAAK,CAAC,SAAS,GAAG,IAAI;AACtB,YAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AACjC,YAAA,MAAM,mBAAmB,GAAG,MAAM,CAAC,mBAAmB,CAAC;AACvD,YAAA,MAAM,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;AAC7C,YAAA,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;AACrC,YAAA,IAAI,SAA2D;AAC/D,YAAA,IAAI,IAA6B;AACjC,YAAA,MAAM,MAAM,GAAG,eAAe,CAC5B,MAAK;AACH,gBAAA,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,yBAAyB,CAAC;AACxD,gBAAA,SAAS,GAAG,eAAe,CAAC,sBAAsB,EAAE,EAAC,mBAAmB,EAAE,WAAW,EAAE,IAAI,EAAC,CAAC;AAC7F,gBAAA,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;AAC1C,gBAAA,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;AAC1B,gBAAA,cAAc,CAAC,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC;AAC7C,gBAAA,SAAS,CAAC,iBAAiB,CAAC,aAAa,EAAE;AAC7C,YAAA,CAAC,EACD,EAAC,QAAQ,EAAE,mBAAmB,EAAC,CAChC;AACD,YAAA,UAAU,CAAC,SAAS,CAAC,MAAK;gBACxB,MAAM,CAAC,OAAO,EAAE;gBAChB,IAAI,SAAS,EAAE;AACb,oBAAA,cAAc,CAAC,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC;oBAC7C,SAAS,CAAC,OAAO,EAAE;gBACrB;gBACA,IAAI,EAAE,MAAM,EAAE;AACd,gBAAA,KAAK,CAAC,SAAS,GAAG,KAAK;AACzB,YAAA,CAAC,CAAC;AACJ,QAAA,CAAC,CAAC;AACH,KAAA,CAAC;AACJ;;ACjEA;;AAEG;;"}
|