ngx-flyout 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +273 -2
- package/fesm2022/ngx-flyout.mjs +281 -0
- package/fesm2022/ngx-flyout.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/flyout-slots.d.ts +27 -0
- package/lib/flyout.component.d.ts +93 -0
- package/lib/flyout.config.d.ts +37 -0
- package/lib/flyout.types.d.ts +27 -0
- package/lib/internal/scroll-lock.d.ts +2 -0
- package/package.json +45 -3
- package/public-api.d.ts +4 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vishal Sharma
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,274 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ngx-flyout
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**An accessible side flyout for Angular.** A panel that opens from the right, over your app, with a heading, your own content and Cancel / OK buttons, and zero dependencies.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/ngx-flyout)
|
|
6
|
+
[](https://www.npmjs.com/package/ngx-flyout)
|
|
7
|
+
[](https://www.npmjs.com/package/ngx-flyout)
|
|
8
|
+
[](https://github.com/vishaalsharmaa/ngx-flyout/blob/main/LICENSE)
|
|
9
|
+
|
|
10
|
+
Think of `<ngx-flyout>` as a side panel that slides over your page: a heading, anything you put inside, and buttons to confirm or cancel. The page behind it stays in view, so users never lose their place.
|
|
11
|
+
|
|
12
|
+
```html
|
|
13
|
+
<button type="button" (click)="editUser.open()">Edit user</button>
|
|
14
|
+
|
|
15
|
+
<ngx-flyout #editUser heading="Edit user" subheading="Changes apply right away" (confirm)="save()">
|
|
16
|
+
Anything you put here shows in the flyout.
|
|
17
|
+
</ngx-flyout>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Table of contents
|
|
21
|
+
|
|
22
|
+
- [Features](#features)
|
|
23
|
+
- [Install](#install)
|
|
24
|
+
- [Usage](#usage)
|
|
25
|
+
- [Inputs](#inputs)
|
|
26
|
+
- [Outputs and methods](#outputs-and-methods)
|
|
27
|
+
- [Examples](#examples)
|
|
28
|
+
- [Two-way binding](#two-way-binding)
|
|
29
|
+
- [Content with its own buttons](#content-with-its-own-buttons)
|
|
30
|
+
- [Close after saving](#close-after-saving)
|
|
31
|
+
- [Custom icon and footer](#custom-icon-and-footer)
|
|
32
|
+
- [Slide animation](#slide-animation)
|
|
33
|
+
- [Accessibility](#accessibility)
|
|
34
|
+
- [Global configuration](#global-configuration)
|
|
35
|
+
- [Development](#development)
|
|
36
|
+
- [License](#license)
|
|
37
|
+
|
|
38
|
+
## Features
|
|
39
|
+
|
|
40
|
+
- **Heading, sub-heading and any content** through `ng-content`
|
|
41
|
+
- **Cancel / OK footer** built in, or your own footer
|
|
42
|
+
- **Three ways to open and close**: template reference, `[(opened)]` two-way binding, or `open()` / `close()` from code
|
|
43
|
+
- **Tells you how it was closed**: Cancel, ×, Escape or a click outside
|
|
44
|
+
- **Accessible**: built on the native `<dialog>`, with focus handling, Escape to close and a stable `id` on every element
|
|
45
|
+
- **Always on top**: the browser's top layer, so no z-index fights, even from inside a scrolling component
|
|
46
|
+
- **Optional slide animation**, off by default and skipped for users who prefer reduced motion
|
|
47
|
+
- **Standalone component**, signal inputs, `OnPush`, and no dependencies besides Angular
|
|
48
|
+
|
|
49
|
+
## Install
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm install ngx-flyout
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Requires Angular 19 or newer.
|
|
56
|
+
|
|
57
|
+
## Usage
|
|
58
|
+
|
|
59
|
+
Import `NgxFlyout` into a standalone component:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import { Component } from '@angular/core';
|
|
63
|
+
import { FlyoutCancelReason, NgxFlyout } from 'ngx-flyout';
|
|
64
|
+
|
|
65
|
+
@Component({
|
|
66
|
+
selector: 'app-page',
|
|
67
|
+
imports: [NgxFlyout],
|
|
68
|
+
template: `
|
|
69
|
+
<button type="button" (click)="details.open()">Project details</button>
|
|
70
|
+
|
|
71
|
+
<ngx-flyout
|
|
72
|
+
#details
|
|
73
|
+
heading="Project details"
|
|
74
|
+
subheading="acme-web · Last deployed 2 hours ago"
|
|
75
|
+
confirmLabel="Open project"
|
|
76
|
+
(confirm)="openProject()"
|
|
77
|
+
(cancel)="onCancel($event)"
|
|
78
|
+
>
|
|
79
|
+
Any content goes here, including <a href="/docs">links</a> and your own components.
|
|
80
|
+
</ngx-flyout>
|
|
81
|
+
`,
|
|
82
|
+
})
|
|
83
|
+
export class PageComponent {
|
|
84
|
+
openProject(): void {
|
|
85
|
+
// OK was clicked; the flyout closes on its own
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
onCancel(reason: FlyoutCancelReason): void {
|
|
89
|
+
// 'button' | 'close' | 'escape' | 'backdrop'
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Clicking the button opens the flyout. Cancel, ×, Escape or OK close it.
|
|
95
|
+
|
|
96
|
+
## Inputs
|
|
97
|
+
|
|
98
|
+
| Input | Type | Default | Description |
|
|
99
|
+
| --- | --- | --- | --- |
|
|
100
|
+
| `opened` | `boolean` | `false` | Whether the flyout is showing. Supports two-way binding: `[(opened)]`. |
|
|
101
|
+
| `heading` | `string` | `''` | Heading at the top. Also the flyout's accessible name. Hidden when empty. |
|
|
102
|
+
| `subheading` | `string` | `''` | Lighter text under the heading. Hidden when empty. |
|
|
103
|
+
| `confirmLabel` | `string` | `'OK'` | Text of the primary button. |
|
|
104
|
+
| `cancelLabel` | `string` | `'Cancel'` | Text of the secondary button. |
|
|
105
|
+
| `confirmDisabled` | `boolean` | `false` | Disables the primary button, for example while a form is invalid or saving. |
|
|
106
|
+
| `showFooter` | `boolean` | `true` | Shows the Cancel / OK footer. Turn off when your content has its own buttons. |
|
|
107
|
+
| `showCloseButton` | `boolean` | `true` | Shows the × button in the header. Escape still closes the flyout. |
|
|
108
|
+
| `closeOnConfirm` | `boolean` | `true` | Closes the flyout after the primary button. Turn off to close it yourself, e.g. after saving. |
|
|
109
|
+
| `hideOnBackdropClick` | `boolean` | `false` | Closes the flyout when the user clicks outside the panel. |
|
|
110
|
+
| `animation` | `'none' \| 'slide'` | `'none'` | `'slide'` slides the flyout in from the right and back out on close. |
|
|
111
|
+
| `id` | `string` | `ngx-flyout-{n}` | Id of the flyout; inner element ids are derived from it. |
|
|
112
|
+
|
|
113
|
+
Boolean inputs also work as bare attributes: `<ngx-flyout hideOnBackdropClick showFooter="false">`.
|
|
114
|
+
|
|
115
|
+
## Outputs and methods
|
|
116
|
+
|
|
117
|
+
| Output | Type | Description |
|
|
118
|
+
| --- | --- | --- |
|
|
119
|
+
| `confirm` | `void` | Emits when the primary (OK) button is clicked. |
|
|
120
|
+
| `cancel` | `'button' \| 'close' \| 'escape' \| 'backdrop'` | Emits when the user dismisses the flyout, with how: the Cancel button, the ×, the Escape key, or a click outside (only with `hideOnBackdropClick`). |
|
|
121
|
+
| `openedChange` | `boolean` | Emits `true` when the flyout opens and `false` when it closes. Used by `[(opened)]`. |
|
|
122
|
+
|
|
123
|
+
| Method | Description |
|
|
124
|
+
| --- | --- |
|
|
125
|
+
| `open()` | Opens the flyout. |
|
|
126
|
+
| `close()` | Closes the flyout. |
|
|
127
|
+
| `toggle()` | Switches between open and closed. |
|
|
128
|
+
|
|
129
|
+
The methods never emit `confirm` or `cancel`. Those only fire when the user clicks a button or presses Escape.
|
|
130
|
+
|
|
131
|
+
## Examples
|
|
132
|
+
|
|
133
|
+
### Two-way binding
|
|
134
|
+
|
|
135
|
+
When the open state lives in your component, bind it with `[(opened)]`. It updates when the user closes the flyout with Cancel, × or Escape.
|
|
136
|
+
|
|
137
|
+
```html
|
|
138
|
+
<!-- settingsOpen = signal(false) -->
|
|
139
|
+
<button type="button" (click)="settingsOpen.set(true)">Settings</button>
|
|
140
|
+
|
|
141
|
+
<ngx-flyout [(opened)]="settingsOpen" heading="Settings" confirmLabel="Apply" (confirm)="apply()">…</ngx-flyout>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Use `[(opened)]`, not one-way `[opened]`. With one-way binding your value stays `true` after the user closes the flyout, and setting it to `true` again does nothing.
|
|
145
|
+
|
|
146
|
+
### Content with its own buttons
|
|
147
|
+
|
|
148
|
+
`showFooter="false"` hides the built-in buttons. Your component emits its own events, and the parent closes the flyout:
|
|
149
|
+
|
|
150
|
+
```html
|
|
151
|
+
<ngx-flyout #userFlyout heading="Edit user" showFooter="false">
|
|
152
|
+
<app-user-form
|
|
153
|
+
(saved)="onSaved($event); userFlyout.close()"
|
|
154
|
+
(cancelled)="userFlyout.close()"
|
|
155
|
+
/>
|
|
156
|
+
</ngx-flyout>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
The form doesn't need to know it is inside a flyout, so you can reuse it anywhere.
|
|
160
|
+
|
|
161
|
+
### Close after saving
|
|
162
|
+
|
|
163
|
+
`closeOnConfirm="false"` keeps the flyout open after OK, so you can close it once an async save has finished:
|
|
164
|
+
|
|
165
|
+
```html
|
|
166
|
+
<ngx-flyout
|
|
167
|
+
#rename
|
|
168
|
+
heading="Rename project"
|
|
169
|
+
[confirmLabel]="saving() ? 'Saving…' : 'Save'"
|
|
170
|
+
[confirmDisabled]="saving()"
|
|
171
|
+
closeOnConfirm="false"
|
|
172
|
+
(confirm)="save(rename)"
|
|
173
|
+
>
|
|
174
|
+
…
|
|
175
|
+
</ngx-flyout>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
async save(flyout: NgxFlyout): Promise<void> {
|
|
180
|
+
this.saving.set(true);
|
|
181
|
+
try {
|
|
182
|
+
await this.projects.rename(this.name);
|
|
183
|
+
flyout.close(); // close() does not emit (cancel)
|
|
184
|
+
} finally {
|
|
185
|
+
this.saving.set(false);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
To reach the flyout from TypeScript without passing it in, use `viewChild.required(NgxFlyout)`.
|
|
191
|
+
|
|
192
|
+
### Custom icon and footer
|
|
193
|
+
|
|
194
|
+
The default slot takes any content. Two named slots add an icon next to the heading, or replace the Cancel / OK buttons:
|
|
195
|
+
|
|
196
|
+
```html
|
|
197
|
+
<ngx-flyout #share heading="Share project">
|
|
198
|
+
<svg ngxFlyoutIcon viewBox="0 0 24 24">…</svg>
|
|
199
|
+
|
|
200
|
+
<input value="https://example.com/p/acme-web" readonly />
|
|
201
|
+
|
|
202
|
+
<div ngxFlyoutFooter>
|
|
203
|
+
<button type="button" (click)="copyLink()">Copy link</button>
|
|
204
|
+
<button type="button" (click)="share.close()">Done</button>
|
|
205
|
+
</div>
|
|
206
|
+
</ngx-flyout>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Import `NgxFlyoutIcon` and `NgxFlyoutFooter` alongside `NgxFlyout` to use them.
|
|
210
|
+
|
|
211
|
+
### Slide animation
|
|
212
|
+
|
|
213
|
+
The flyout appears at once by default. With `animation="slide"` it slides in from the right and back out on close:
|
|
214
|
+
|
|
215
|
+
```html
|
|
216
|
+
<ngx-flyout heading="Filters" animation="slide">…</ngx-flyout>
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
There is no animation for users who prefer reduced motion. In browsers without the newer CSS it uses, the flyout simply appears.
|
|
220
|
+
|
|
221
|
+
## Accessibility
|
|
222
|
+
|
|
223
|
+
With `id="edit-user"`, the flyout renders:
|
|
224
|
+
|
|
225
|
+
| Element | id | Accessibility |
|
|
226
|
+
| --- | --- | --- |
|
|
227
|
+
| Flyout | `edit-user` | Native modal `<dialog>`, `aria-labelledby="edit-user-heading"`, `aria-describedby="edit-user-subheading"` |
|
|
228
|
+
| Heading | `edit-user-heading` | `<h2>` |
|
|
229
|
+
| Sub-heading | `edit-user-subheading` | |
|
|
230
|
+
| Body | `edit-user-body` | |
|
|
231
|
+
| Close button | `edit-user-close` | `aria-label="Close"` |
|
|
232
|
+
|
|
233
|
+
- While the flyout is open, the page behind it can't be clicked or reached with the keyboard.
|
|
234
|
+
- Focus moves into the flyout when it opens and returns to the element that opened it when it closes.
|
|
235
|
+
- Escape closes it, and page scrolling is locked while it is open.
|
|
236
|
+
- All buttons are at least 44px tall.
|
|
237
|
+
- All screen-reader and button text can be translated with [global configuration](#global-configuration).
|
|
238
|
+
|
|
239
|
+
## Global configuration
|
|
240
|
+
|
|
241
|
+
Set defaults for every flyout in `app.config.ts`. Everything is optional:
|
|
242
|
+
|
|
243
|
+
```ts
|
|
244
|
+
import { ApplicationConfig } from '@angular/core';
|
|
245
|
+
import { provideFlyout } from 'ngx-flyout';
|
|
246
|
+
|
|
247
|
+
export const appConfig: ApplicationConfig = {
|
|
248
|
+
providers: [
|
|
249
|
+
provideFlyout({
|
|
250
|
+
showFooter: true,
|
|
251
|
+
showCloseButton: true,
|
|
252
|
+
closeOnConfirm: true,
|
|
253
|
+
hideOnBackdropClick: false,
|
|
254
|
+
animation: 'slide',
|
|
255
|
+
// Translate the button and screen-reader text
|
|
256
|
+
labels: { confirm: 'Speichern', cancel: 'Abbrechen', close: 'Schließen' },
|
|
257
|
+
}),
|
|
258
|
+
],
|
|
259
|
+
};
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Inputs on a single flyout always win over these defaults.
|
|
263
|
+
|
|
264
|
+
## Development
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
npm install
|
|
268
|
+
npm run build:lib # builds dist/ngx-flyout
|
|
269
|
+
npm start # demo app at http://localhost:4200
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## License
|
|
273
|
+
|
|
274
|
+
[MIT](https://github.com/vishaalsharmaa/ngx-flyout/blob/main/LICENSE) © 2026 Vishal Sharma
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, makeEnvironmentProviders, Directive, inject, PLATFORM_ID, model, input, booleanAttribute, output, viewChild, contentChild, computed, effect, untracked, DestroyRef, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { DOCUMENT, isPlatformBrowser } from '@angular/common';
|
|
4
|
+
|
|
5
|
+
/** Input transform for `animation`: also accepts `true` (slide) and `false` / `null` (none). */
|
|
6
|
+
function toFlyoutAnimation(value) {
|
|
7
|
+
return value === 'slide' || value === true ? 'slide' : 'none';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const DEFAULT_FLYOUT_LABELS = {
|
|
11
|
+
confirm: 'OK',
|
|
12
|
+
cancel: 'Cancel',
|
|
13
|
+
close: 'Close',
|
|
14
|
+
};
|
|
15
|
+
const DEFAULT_FLYOUT_CONFIG = {
|
|
16
|
+
closeOnConfirm: true,
|
|
17
|
+
hideOnBackdropClick: false,
|
|
18
|
+
showCloseButton: true,
|
|
19
|
+
showFooter: true,
|
|
20
|
+
animation: 'none',
|
|
21
|
+
labels: DEFAULT_FLYOUT_LABELS,
|
|
22
|
+
};
|
|
23
|
+
const NGX_FLYOUT_CONFIG = new InjectionToken('NGX_FLYOUT_CONFIG', {
|
|
24
|
+
providedIn: 'root',
|
|
25
|
+
factory: () => DEFAULT_FLYOUT_CONFIG,
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Sets app-wide defaults for flyouts. Optional: flyouts work without it.
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* providers: [provideFlyout({ animation: 'slide', hideOnBackdropClick: true, labels: { confirm: 'Save' } })]
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
function provideFlyout(options = {}) {
|
|
35
|
+
const d = DEFAULT_FLYOUT_CONFIG;
|
|
36
|
+
const config = {
|
|
37
|
+
closeOnConfirm: options.closeOnConfirm ?? d.closeOnConfirm,
|
|
38
|
+
hideOnBackdropClick: options.hideOnBackdropClick ?? d.hideOnBackdropClick,
|
|
39
|
+
showCloseButton: options.showCloseButton ?? d.showCloseButton,
|
|
40
|
+
showFooter: options.showFooter ?? d.showFooter,
|
|
41
|
+
animation: options.animation ?? d.animation,
|
|
42
|
+
labels: { ...DEFAULT_FLYOUT_LABELS, ...options.labels },
|
|
43
|
+
};
|
|
44
|
+
return makeEnvironmentProviders([{ provide: NGX_FLYOUT_CONFIG, useValue: config }]);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Marks projected content shown in the icon tile next to the heading.
|
|
49
|
+
* The tile only appears when this slot is used.
|
|
50
|
+
*
|
|
51
|
+
* ```html
|
|
52
|
+
* <ngx-flyout heading="Project details"><svg ngxFlyoutIcon>…</svg>Body</ngx-flyout>
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
class NgxFlyoutIcon {
|
|
56
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: NgxFlyoutIcon, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
57
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.25", type: NgxFlyoutIcon, isStandalone: true, selector: "[ngxFlyoutIcon]", ngImport: i0 });
|
|
58
|
+
}
|
|
59
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: NgxFlyoutIcon, decorators: [{
|
|
60
|
+
type: Directive,
|
|
61
|
+
args: [{ selector: '[ngxFlyoutIcon]' }]
|
|
62
|
+
}] });
|
|
63
|
+
/**
|
|
64
|
+
* Marks projected content that replaces the built-in Cancel / OK buttons.
|
|
65
|
+
*
|
|
66
|
+
* ```html
|
|
67
|
+
* <ngx-flyout heading="Share">
|
|
68
|
+
* Body
|
|
69
|
+
* <div ngxFlyoutFooter><button (click)="flyout.close()">Done</button></div>
|
|
70
|
+
* </ngx-flyout>
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
class NgxFlyoutFooter {
|
|
74
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: NgxFlyoutFooter, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
75
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.25", type: NgxFlyoutFooter, isStandalone: true, selector: "[ngxFlyoutFooter]", ngImport: i0 });
|
|
76
|
+
}
|
|
77
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: NgxFlyoutFooter, decorators: [{
|
|
78
|
+
type: Directive,
|
|
79
|
+
args: [{ selector: '[ngxFlyoutFooter]' }]
|
|
80
|
+
}] });
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Locks page scrolling while at least one flyout is open.
|
|
84
|
+
* Counts locks so that closing a nested flyout keeps the page locked
|
|
85
|
+
* until the last one closes.
|
|
86
|
+
*/
|
|
87
|
+
let lockCount = 0;
|
|
88
|
+
let saved = null;
|
|
89
|
+
function lockScroll(doc) {
|
|
90
|
+
if (lockCount++ > 0)
|
|
91
|
+
return;
|
|
92
|
+
const root = doc.documentElement;
|
|
93
|
+
const win = doc.defaultView;
|
|
94
|
+
// Keep the layout from jumping when the scrollbar disappears.
|
|
95
|
+
const scrollbar = win ? win.innerWidth - root.clientWidth : 0;
|
|
96
|
+
saved = { overflow: root.style.overflow, paddingRight: root.style.paddingRight };
|
|
97
|
+
root.style.overflow = 'hidden';
|
|
98
|
+
if (scrollbar > 0) {
|
|
99
|
+
root.style.paddingRight = `${scrollbar}px`;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function unlockScroll(doc) {
|
|
103
|
+
if (lockCount === 0 || --lockCount > 0)
|
|
104
|
+
return;
|
|
105
|
+
const root = doc.documentElement;
|
|
106
|
+
if (saved) {
|
|
107
|
+
root.style.overflow = saved.overflow;
|
|
108
|
+
root.style.paddingRight = saved.paddingRight;
|
|
109
|
+
saved = null;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
let nextId = 0;
|
|
114
|
+
/**
|
|
115
|
+
* A side flyout that slides in from the right, over the whole app.
|
|
116
|
+
* It has a heading, your projected content, and Cancel / OK buttons.
|
|
117
|
+
*
|
|
118
|
+
* Open it with a template reference, `[(opened)]`, or from code:
|
|
119
|
+
*
|
|
120
|
+
* ```html
|
|
121
|
+
* <button (click)="flyout.open()">Edit user</button>
|
|
122
|
+
*
|
|
123
|
+
* <ngx-flyout #flyout heading="Edit user" (confirm)="save()" (cancel)="discard()">
|
|
124
|
+
* <app-user-form />
|
|
125
|
+
* </ngx-flyout>
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
class NgxFlyout {
|
|
129
|
+
config = inject(NGX_FLYOUT_CONFIG);
|
|
130
|
+
document = inject(DOCUMENT);
|
|
131
|
+
isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
132
|
+
/** Whether the flyout is showing. Supports two-way binding: `[(opened)]`. */
|
|
133
|
+
opened = model(false);
|
|
134
|
+
/** Heading in the header. Also used as the flyout's accessible name. */
|
|
135
|
+
heading = input('');
|
|
136
|
+
/** Lighter line under the heading. Leave empty to hide it. */
|
|
137
|
+
subheading = input('');
|
|
138
|
+
/** Text of the primary button. Default: `'OK'`, or `provideFlyout({ labels })`. */
|
|
139
|
+
confirmLabel = input('');
|
|
140
|
+
/** Text of the secondary button. Default: `'Cancel'`, or `provideFlyout({ labels })`. */
|
|
141
|
+
cancelLabel = input('');
|
|
142
|
+
/** Disables the primary button, for example while a form is invalid or saving. */
|
|
143
|
+
confirmDisabled = input(false, { transform: booleanAttribute });
|
|
144
|
+
/** Show the built-in Cancel / OK footer. Turn off when your content has its own buttons. */
|
|
145
|
+
showFooter = input(this.config.showFooter, { transform: booleanAttribute });
|
|
146
|
+
/** Close automatically after the primary button is clicked. Turn off to close it yourself, e.g. after saving. */
|
|
147
|
+
closeOnConfirm = input(this.config.closeOnConfirm, { transform: booleanAttribute });
|
|
148
|
+
/** A click outside the panel cancels and closes the flyout. Default: `false`. */
|
|
149
|
+
hideOnBackdropClick = input(this.config.hideOnBackdropClick, { transform: booleanAttribute });
|
|
150
|
+
/** Show the × button in the header. Escape still closes the flyout when it is hidden. Default: `true`. */
|
|
151
|
+
showCloseButton = input(this.config.showCloseButton, { transform: booleanAttribute });
|
|
152
|
+
/**
|
|
153
|
+
* `'slide'`: slides in from the right and back out on close. `'none'` (default): appears at once.
|
|
154
|
+
* The slide is skipped for users who prefer reduced motion.
|
|
155
|
+
*/
|
|
156
|
+
animation = input(this.config.animation, { transform: toFlyoutAnimation });
|
|
157
|
+
/** Id of the dialog element. Inner elements get ids derived from it. Generated when not set. */
|
|
158
|
+
id = input(`ngx-flyout-${nextId++}`);
|
|
159
|
+
/** The primary (OK) button was clicked. */
|
|
160
|
+
confirm = output();
|
|
161
|
+
/** The user dismissed the flyout: Cancel, ×, Escape, or a backdrop click (with `hideOnBackdropClick`). Not emitted by `close()`. */
|
|
162
|
+
cancel = output();
|
|
163
|
+
dialog = viewChild('dialog');
|
|
164
|
+
projectedIcon = contentChild(NgxFlyoutIcon);
|
|
165
|
+
resolvedConfirmLabel = computed(() => this.confirmLabel() || this.config.labels.confirm);
|
|
166
|
+
resolvedCancelLabel = computed(() => this.cancelLabel() || this.config.labels.cancel);
|
|
167
|
+
closeLabel = this.config.labels.close;
|
|
168
|
+
ids = computed(() => {
|
|
169
|
+
const id = this.id();
|
|
170
|
+
return {
|
|
171
|
+
dialog: id,
|
|
172
|
+
heading: `${id}-heading`,
|
|
173
|
+
subheading: `${id}-subheading`,
|
|
174
|
+
body: `${id}-body`,
|
|
175
|
+
close: `${id}-close`,
|
|
176
|
+
};
|
|
177
|
+
});
|
|
178
|
+
/** Element that had focus before opening; focus goes back to it on close. */
|
|
179
|
+
returnFocus = null;
|
|
180
|
+
scrollLocked = false;
|
|
181
|
+
/** Whether the current pointer press started on the backdrop. */
|
|
182
|
+
pressedBackdrop = false;
|
|
183
|
+
constructor() {
|
|
184
|
+
effect(() => {
|
|
185
|
+
const isOpen = this.opened();
|
|
186
|
+
const dialog = this.dialog()?.nativeElement;
|
|
187
|
+
if (!dialog || !this.isBrowser)
|
|
188
|
+
return;
|
|
189
|
+
untracked(() => (isOpen ? this.show(dialog) : this.hide(dialog)));
|
|
190
|
+
});
|
|
191
|
+
inject(DestroyRef).onDestroy(() => this.releaseScroll());
|
|
192
|
+
}
|
|
193
|
+
/** Opens the flyout. */
|
|
194
|
+
open() {
|
|
195
|
+
this.opened.set(true);
|
|
196
|
+
}
|
|
197
|
+
/** Closes the flyout without emitting `cancel` or `confirm`. */
|
|
198
|
+
close() {
|
|
199
|
+
this.opened.set(false);
|
|
200
|
+
}
|
|
201
|
+
/** Opens the flyout when closed, closes it when open. */
|
|
202
|
+
toggle() {
|
|
203
|
+
this.opened.update((value) => !value);
|
|
204
|
+
}
|
|
205
|
+
onConfirm() {
|
|
206
|
+
if (this.confirmDisabled())
|
|
207
|
+
return;
|
|
208
|
+
this.confirm.emit();
|
|
209
|
+
if (this.closeOnConfirm())
|
|
210
|
+
this.close();
|
|
211
|
+
}
|
|
212
|
+
dismiss(reason) {
|
|
213
|
+
this.cancel.emit(reason);
|
|
214
|
+
this.close();
|
|
215
|
+
}
|
|
216
|
+
/** Escape key: the dialog's native `cancel` event. Closing goes through `opened` instead. */
|
|
217
|
+
onNativeCancel(event) {
|
|
218
|
+
event.preventDefault();
|
|
219
|
+
this.dismiss('escape');
|
|
220
|
+
}
|
|
221
|
+
/** The dialog closed on its own (e.g. a `<form method="dialog">` inside it): keep `opened` in sync. */
|
|
222
|
+
onNativeClose() {
|
|
223
|
+
if (this.opened())
|
|
224
|
+
this.close();
|
|
225
|
+
}
|
|
226
|
+
onPointerDown(event) {
|
|
227
|
+
this.pressedBackdrop = event.target === event.currentTarget;
|
|
228
|
+
}
|
|
229
|
+
/** The dialog covers the viewport; a click on the dialog itself (not the panel) is a backdrop click. */
|
|
230
|
+
onDialogClick(event) {
|
|
231
|
+
const onBackdrop = event.target === event.currentTarget && this.pressedBackdrop;
|
|
232
|
+
this.pressedBackdrop = false;
|
|
233
|
+
if (onBackdrop && this.hideOnBackdropClick())
|
|
234
|
+
this.dismiss('backdrop');
|
|
235
|
+
}
|
|
236
|
+
show(dialog) {
|
|
237
|
+
if (dialog.open)
|
|
238
|
+
return;
|
|
239
|
+
const active = this.document.activeElement;
|
|
240
|
+
this.returnFocus = active instanceof HTMLElement ? active : null;
|
|
241
|
+
dialog.showModal();
|
|
242
|
+
if (!this.scrollLocked) {
|
|
243
|
+
lockScroll(this.document);
|
|
244
|
+
this.scrollLocked = true;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
hide(dialog) {
|
|
248
|
+
if (dialog.open)
|
|
249
|
+
dialog.close();
|
|
250
|
+
if (!this.scrollLocked)
|
|
251
|
+
return;
|
|
252
|
+
this.releaseScroll();
|
|
253
|
+
const target = this.returnFocus;
|
|
254
|
+
this.returnFocus = null;
|
|
255
|
+
if (target?.isConnected)
|
|
256
|
+
target.focus();
|
|
257
|
+
}
|
|
258
|
+
releaseScroll() {
|
|
259
|
+
if (!this.scrollLocked)
|
|
260
|
+
return;
|
|
261
|
+
unlockScroll(this.document);
|
|
262
|
+
this.scrollLocked = false;
|
|
263
|
+
}
|
|
264
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: NgxFlyout, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
265
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: NgxFlyout, isStandalone: true, selector: "ngx-flyout", inputs: { opened: { classPropertyName: "opened", publicName: "opened", isSignal: true, isRequired: false, transformFunction: null }, heading: { classPropertyName: "heading", publicName: "heading", isSignal: true, isRequired: false, transformFunction: null }, subheading: { classPropertyName: "subheading", publicName: "subheading", isSignal: true, isRequired: false, transformFunction: null }, confirmLabel: { classPropertyName: "confirmLabel", publicName: "confirmLabel", isSignal: true, isRequired: false, transformFunction: null }, cancelLabel: { classPropertyName: "cancelLabel", publicName: "cancelLabel", isSignal: true, isRequired: false, transformFunction: null }, confirmDisabled: { classPropertyName: "confirmDisabled", publicName: "confirmDisabled", isSignal: true, isRequired: false, transformFunction: null }, showFooter: { classPropertyName: "showFooter", publicName: "showFooter", isSignal: true, isRequired: false, transformFunction: null }, closeOnConfirm: { classPropertyName: "closeOnConfirm", publicName: "closeOnConfirm", isSignal: true, isRequired: false, transformFunction: null }, hideOnBackdropClick: { classPropertyName: "hideOnBackdropClick", publicName: "hideOnBackdropClick", isSignal: true, isRequired: false, transformFunction: null }, showCloseButton: { classPropertyName: "showCloseButton", publicName: "showCloseButton", isSignal: true, isRequired: false, transformFunction: null }, animation: { classPropertyName: "animation", publicName: "animation", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { opened: "openedChange", confirm: "confirm", cancel: "cancel" }, host: { classAttribute: "ngx-flyout-host" }, queries: [{ propertyName: "projectedIcon", first: true, predicate: NgxFlyoutIcon, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "dialog", first: true, predicate: ["dialog"], descendants: true, isSignal: true }], ngImport: i0, template: "<dialog\n #dialog\n class=\"ngx-flyout\"\n [class.ngx-flyout--slide]=\"animation() === 'slide'\"\n [id]=\"ids().dialog\"\n [attr.aria-labelledby]=\"heading() ? ids().heading : null\"\n [attr.aria-describedby]=\"subheading() ? ids().subheading : null\"\n (cancel)=\"onNativeCancel($event)\"\n (close)=\"onNativeClose()\"\n (pointerdown)=\"onPointerDown($event)\"\n (click)=\"onDialogClick($event)\"\n>\n <div class=\"ngx-flyout__panel\">\n <header class=\"ngx-flyout__header\">\n @if (projectedIcon()) {\n <span class=\"ngx-flyout__icon\" aria-hidden=\"true\">\n <ng-content select=\"[ngxFlyoutIcon]\" />\n </span>\n }\n <div class=\"ngx-flyout__titles\">\n @if (heading()) {\n <h2 class=\"ngx-flyout__heading\" [id]=\"ids().heading\">{{ heading() }}</h2>\n }\n @if (subheading()) {\n <p class=\"ngx-flyout__subheading\" [id]=\"ids().subheading\">{{ subheading() }}</p>\n }\n </div>\n @if (showCloseButton()) {\n <button\n type=\"button\"\n class=\"ngx-flyout__close\"\n [id]=\"ids().close\"\n [attr.aria-label]=\"closeLabel\"\n [attr.title]=\"closeLabel\"\n (click)=\"dismiss('close')\"\n >\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </svg>\n </button>\n }\n </header>\n\n <div class=\"ngx-flyout__body\" [id]=\"ids().body\">\n <ng-content />\n </div>\n\n @if (showFooter()) {\n <footer class=\"ngx-flyout__footer\">\n <ng-content select=\"[ngxFlyoutFooter]\">\n <button type=\"button\" class=\"ngx-flyout__btn ngx-flyout__btn--secondary\" (click)=\"dismiss('button')\">\n {{ resolvedCancelLabel() }}\n </button>\n <button\n type=\"button\"\n class=\"ngx-flyout__btn ngx-flyout__btn--primary\"\n [disabled]=\"confirmDisabled()\"\n (click)=\"onConfirm()\"\n >\n {{ resolvedConfirmLabel() }}\n </button>\n </ng-content>\n </footer>\n }\n </div>\n</dialog>\n", styles: [":host{display:contents}.ngx-flyout{--_accent: var(--ngx-flyout-accent, #0f6f8c);--_on-accent: var(--ngx-flyout-on-accent, #ffffff);--_bg: var(--ngx-flyout-bg, #ffffff);--_ink: var(--ngx-flyout-ink, #1b2230);--_muted: var(--ngx-flyout-muted, color-mix(in srgb, var(--_ink) 72%, var(--_bg)));--_line: var(--ngx-flyout-border, color-mix(in srgb, var(--_ink) 12%, var(--_bg)));--_backdrop: var(--ngx-flyout-backdrop, rgba(15, 23, 42, .45));--_width: var(--ngx-flyout-width, 440px);--_radius: var(--ngx-flyout-radius, 8px);--_duration: var(--ngx-flyout-duration, .28s);position:fixed;inset:0;width:100%;height:100%;max-width:none;max-height:none;margin:0;padding:0;border:0;overflow:hidden;background:transparent;color:var(--_ink);font:inherit}.ngx-flyout::backdrop{background:transparent}.ngx-flyout[open]{background:var(--_backdrop)}.ngx-flyout__panel{position:absolute;top:0;right:0;bottom:0;width:min(var(--_width),100%);box-sizing:border-box;display:flex;flex-direction:column;background:var(--_bg);box-shadow:-12px 0 40px #0f172a2e}.ngx-flyout--slide{transition:background-color var(--_duration) ease-out}.ngx-flyout--slide .ngx-flyout__panel{transform:translate(100%);transition:transform calc(var(--_duration) * .85) cubic-bezier(.4,0,1,1)}.ngx-flyout--slide[open] .ngx-flyout__panel{transform:none;transition:transform var(--_duration) cubic-bezier(.16,1,.3,1)}@supports (overlay: auto){.ngx-flyout--slide{transition:background-color var(--_duration) ease-out,display var(--_duration) allow-discrete,overlay var(--_duration) allow-discrete}}@starting-style{.ngx-flyout--slide[open]{background:transparent}.ngx-flyout--slide[open] .ngx-flyout__panel{transform:translate(100%)}}@media(prefers-reduced-motion:reduce){.ngx-flyout--slide,.ngx-flyout--slide .ngx-flyout__panel,.ngx-flyout--slide[open] .ngx-flyout__panel{transition:none}}.ngx-flyout__header{flex:none;display:flex;align-items:flex-start;gap:14px;padding:22px 24px}.ngx-flyout__icon{flex:none;width:40px;height:40px;border-radius:10px;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--_accent) 14%,var(--_bg));color:var(--_accent)}.ngx-flyout__icon ::ng-deep svg{width:22px;height:22px;display:block}.ngx-flyout__titles{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px;align-self:center;overflow-wrap:anywhere}.ngx-flyout__heading{margin:0;font-size:1.1875rem;font-weight:600;line-height:1.3;color:var(--_ink)}.ngx-flyout__subheading{margin:0;font-size:.875rem;line-height:1.4;color:var(--_muted)}.ngx-flyout__close{flex:none;width:44px;height:44px;margin:-8px -10px -8px 0;padding:0;border:0;border-radius:var(--_radius);background:transparent;color:var(--_muted);display:flex;align-items:center;justify-content:center;cursor:pointer}.ngx-flyout__close svg{width:20px;height:20px}.ngx-flyout__close:hover{background:color-mix(in srgb,var(--_ink) 6%,var(--_bg));color:var(--_ink)}.ngx-flyout__body{flex:1 1 auto;min-height:0;overflow:auto;overscroll-behavior:contain;padding:24px;font-size:.9375rem;line-height:1.6}.ngx-flyout__footer{flex:none;display:flex;flex-wrap:wrap;justify-content:flex-end;gap:10px;padding:16px 24px;border-top:1px solid var(--_line)}.ngx-flyout__btn{min-height:44px;padding:0 18px;border-radius:var(--_radius);font:inherit;font-size:.875rem;line-height:1.2;cursor:pointer}.ngx-flyout__btn--secondary{border:1px solid color-mix(in srgb,var(--_ink) 22%,var(--_bg));background:var(--_bg);color:var(--_ink);font-weight:500}.ngx-flyout__btn--secondary:hover{background:color-mix(in srgb,var(--_ink) 5%,var(--_bg))}.ngx-flyout__btn--primary{border:1px solid var(--_accent);background:var(--_accent);color:var(--_on-accent);font-weight:600}.ngx-flyout__btn--primary:hover:not(:disabled){background:color-mix(in srgb,var(--_accent) 86%,#000000)}.ngx-flyout__btn--primary:disabled{opacity:.5;cursor:not-allowed}.ngx-flyout__close:focus-visible,.ngx-flyout__btn:focus-visible{outline:2px solid var(--_accent);outline-offset:2px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
266
|
+
}
|
|
267
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: NgxFlyout, decorators: [{
|
|
268
|
+
type: Component,
|
|
269
|
+
args: [{ selector: 'ngx-flyout', changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'ngx-flyout-host' }, template: "<dialog\n #dialog\n class=\"ngx-flyout\"\n [class.ngx-flyout--slide]=\"animation() === 'slide'\"\n [id]=\"ids().dialog\"\n [attr.aria-labelledby]=\"heading() ? ids().heading : null\"\n [attr.aria-describedby]=\"subheading() ? ids().subheading : null\"\n (cancel)=\"onNativeCancel($event)\"\n (close)=\"onNativeClose()\"\n (pointerdown)=\"onPointerDown($event)\"\n (click)=\"onDialogClick($event)\"\n>\n <div class=\"ngx-flyout__panel\">\n <header class=\"ngx-flyout__header\">\n @if (projectedIcon()) {\n <span class=\"ngx-flyout__icon\" aria-hidden=\"true\">\n <ng-content select=\"[ngxFlyoutIcon]\" />\n </span>\n }\n <div class=\"ngx-flyout__titles\">\n @if (heading()) {\n <h2 class=\"ngx-flyout__heading\" [id]=\"ids().heading\">{{ heading() }}</h2>\n }\n @if (subheading()) {\n <p class=\"ngx-flyout__subheading\" [id]=\"ids().subheading\">{{ subheading() }}</p>\n }\n </div>\n @if (showCloseButton()) {\n <button\n type=\"button\"\n class=\"ngx-flyout__close\"\n [id]=\"ids().close\"\n [attr.aria-label]=\"closeLabel\"\n [attr.title]=\"closeLabel\"\n (click)=\"dismiss('close')\"\n >\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </svg>\n </button>\n }\n </header>\n\n <div class=\"ngx-flyout__body\" [id]=\"ids().body\">\n <ng-content />\n </div>\n\n @if (showFooter()) {\n <footer class=\"ngx-flyout__footer\">\n <ng-content select=\"[ngxFlyoutFooter]\">\n <button type=\"button\" class=\"ngx-flyout__btn ngx-flyout__btn--secondary\" (click)=\"dismiss('button')\">\n {{ resolvedCancelLabel() }}\n </button>\n <button\n type=\"button\"\n class=\"ngx-flyout__btn ngx-flyout__btn--primary\"\n [disabled]=\"confirmDisabled()\"\n (click)=\"onConfirm()\"\n >\n {{ resolvedConfirmLabel() }}\n </button>\n </ng-content>\n </footer>\n }\n </div>\n</dialog>\n", styles: [":host{display:contents}.ngx-flyout{--_accent: var(--ngx-flyout-accent, #0f6f8c);--_on-accent: var(--ngx-flyout-on-accent, #ffffff);--_bg: var(--ngx-flyout-bg, #ffffff);--_ink: var(--ngx-flyout-ink, #1b2230);--_muted: var(--ngx-flyout-muted, color-mix(in srgb, var(--_ink) 72%, var(--_bg)));--_line: var(--ngx-flyout-border, color-mix(in srgb, var(--_ink) 12%, var(--_bg)));--_backdrop: var(--ngx-flyout-backdrop, rgba(15, 23, 42, .45));--_width: var(--ngx-flyout-width, 440px);--_radius: var(--ngx-flyout-radius, 8px);--_duration: var(--ngx-flyout-duration, .28s);position:fixed;inset:0;width:100%;height:100%;max-width:none;max-height:none;margin:0;padding:0;border:0;overflow:hidden;background:transparent;color:var(--_ink);font:inherit}.ngx-flyout::backdrop{background:transparent}.ngx-flyout[open]{background:var(--_backdrop)}.ngx-flyout__panel{position:absolute;top:0;right:0;bottom:0;width:min(var(--_width),100%);box-sizing:border-box;display:flex;flex-direction:column;background:var(--_bg);box-shadow:-12px 0 40px #0f172a2e}.ngx-flyout--slide{transition:background-color var(--_duration) ease-out}.ngx-flyout--slide .ngx-flyout__panel{transform:translate(100%);transition:transform calc(var(--_duration) * .85) cubic-bezier(.4,0,1,1)}.ngx-flyout--slide[open] .ngx-flyout__panel{transform:none;transition:transform var(--_duration) cubic-bezier(.16,1,.3,1)}@supports (overlay: auto){.ngx-flyout--slide{transition:background-color var(--_duration) ease-out,display var(--_duration) allow-discrete,overlay var(--_duration) allow-discrete}}@starting-style{.ngx-flyout--slide[open]{background:transparent}.ngx-flyout--slide[open] .ngx-flyout__panel{transform:translate(100%)}}@media(prefers-reduced-motion:reduce){.ngx-flyout--slide,.ngx-flyout--slide .ngx-flyout__panel,.ngx-flyout--slide[open] .ngx-flyout__panel{transition:none}}.ngx-flyout__header{flex:none;display:flex;align-items:flex-start;gap:14px;padding:22px 24px}.ngx-flyout__icon{flex:none;width:40px;height:40px;border-radius:10px;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--_accent) 14%,var(--_bg));color:var(--_accent)}.ngx-flyout__icon ::ng-deep svg{width:22px;height:22px;display:block}.ngx-flyout__titles{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px;align-self:center;overflow-wrap:anywhere}.ngx-flyout__heading{margin:0;font-size:1.1875rem;font-weight:600;line-height:1.3;color:var(--_ink)}.ngx-flyout__subheading{margin:0;font-size:.875rem;line-height:1.4;color:var(--_muted)}.ngx-flyout__close{flex:none;width:44px;height:44px;margin:-8px -10px -8px 0;padding:0;border:0;border-radius:var(--_radius);background:transparent;color:var(--_muted);display:flex;align-items:center;justify-content:center;cursor:pointer}.ngx-flyout__close svg{width:20px;height:20px}.ngx-flyout__close:hover{background:color-mix(in srgb,var(--_ink) 6%,var(--_bg));color:var(--_ink)}.ngx-flyout__body{flex:1 1 auto;min-height:0;overflow:auto;overscroll-behavior:contain;padding:24px;font-size:.9375rem;line-height:1.6}.ngx-flyout__footer{flex:none;display:flex;flex-wrap:wrap;justify-content:flex-end;gap:10px;padding:16px 24px;border-top:1px solid var(--_line)}.ngx-flyout__btn{min-height:44px;padding:0 18px;border-radius:var(--_radius);font:inherit;font-size:.875rem;line-height:1.2;cursor:pointer}.ngx-flyout__btn--secondary{border:1px solid color-mix(in srgb,var(--_ink) 22%,var(--_bg));background:var(--_bg);color:var(--_ink);font-weight:500}.ngx-flyout__btn--secondary:hover{background:color-mix(in srgb,var(--_ink) 5%,var(--_bg))}.ngx-flyout__btn--primary{border:1px solid var(--_accent);background:var(--_accent);color:var(--_on-accent);font-weight:600}.ngx-flyout__btn--primary:hover:not(:disabled){background:color-mix(in srgb,var(--_accent) 86%,#000000)}.ngx-flyout__btn--primary:disabled{opacity:.5;cursor:not-allowed}.ngx-flyout__close:focus-visible,.ngx-flyout__btn:focus-visible{outline:2px solid var(--_accent);outline-offset:2px}\n"] }]
|
|
270
|
+
}], ctorParameters: () => [] });
|
|
271
|
+
|
|
272
|
+
/*
|
|
273
|
+
* Public API Surface of ngx-flyout
|
|
274
|
+
*/
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Generated bundle index. Do not edit.
|
|
278
|
+
*/
|
|
279
|
+
|
|
280
|
+
export { DEFAULT_FLYOUT_CONFIG, DEFAULT_FLYOUT_LABELS, NGX_FLYOUT_CONFIG, NgxFlyout, NgxFlyoutFooter, NgxFlyoutIcon, provideFlyout, toFlyoutAnimation };
|
|
281
|
+
//# sourceMappingURL=ngx-flyout.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngx-flyout.mjs","sources":["../../../projects/ngx-flyout/src/lib/flyout.types.ts","../../../projects/ngx-flyout/src/lib/flyout.config.ts","../../../projects/ngx-flyout/src/lib/flyout-slots.ts","../../../projects/ngx-flyout/src/lib/internal/scroll-lock.ts","../../../projects/ngx-flyout/src/lib/flyout.component.ts","../../../projects/ngx-flyout/src/lib/flyout.component.html","../../../projects/ngx-flyout/src/public-api.ts","../../../projects/ngx-flyout/src/ngx-flyout.ts"],"sourcesContent":["/**\n * How the user dismissed the flyout, passed with the `cancel` output.\n *\n * - `button`: the footer's Cancel button\n * - `close`: the × button in the header\n * - `escape`: the Escape key\n * - `backdrop`: a click outside the panel (only when `hideOnBackdropClick` is on)\n */\nexport type FlyoutCancelReason = 'button' | 'close' | 'escape' | 'backdrop';\n\n/**\n * How the flyout opens and closes.\n *\n * - `none`: it appears and disappears at once (default)\n * - `slide`: it slides in from the right and back out again\n */\nexport type FlyoutAnimation = 'none' | 'slide';\n\n/** Input transform for `animation`: also accepts `true` (slide) and `false` / `null` (none). */\nexport function toFlyoutAnimation(value: FlyoutAnimation | boolean | null | undefined): FlyoutAnimation {\n return value === 'slide' || value === true ? 'slide' : 'none';\n}\n\n/** Default text for the built-in buttons. Override these to translate them. */\nexport interface FlyoutLabels {\n /** Primary footer button. */\n confirm: string;\n /** Secondary footer button. */\n cancel: string;\n /** Screen-reader name of the × button. */\n close: string;\n}\n","import { EnvironmentProviders, InjectionToken, makeEnvironmentProviders } from '@angular/core';\nimport { FlyoutAnimation, FlyoutLabels } from './flyout.types';\n\n/** App-wide settings for every `<ngx-flyout>`. */\nexport interface NgxFlyoutConfig {\n /** Default for the `closeOnConfirm` input. Default: `true`. */\n closeOnConfirm: boolean;\n /** Default for the `hideOnBackdropClick` input. Default: `false`. */\n hideOnBackdropClick: boolean;\n /** Default for the `showCloseButton` input. Default: `true`. */\n showCloseButton: boolean;\n /** Default for the `showFooter` input. Default: `true`. */\n showFooter: boolean;\n /** Default for the `animation` input. Default: `'none'`. */\n animation: FlyoutAnimation;\n /** Default button text. Override these to translate them. */\n labels: FlyoutLabels;\n}\n\nexport const DEFAULT_FLYOUT_LABELS: FlyoutLabels = {\n confirm: 'OK',\n cancel: 'Cancel',\n close: 'Close',\n};\n\nexport const DEFAULT_FLYOUT_CONFIG: NgxFlyoutConfig = {\n closeOnConfirm: true,\n hideOnBackdropClick: false,\n showCloseButton: true,\n showFooter: true,\n animation: 'none',\n labels: DEFAULT_FLYOUT_LABELS,\n};\n\nexport const NGX_FLYOUT_CONFIG = new InjectionToken<NgxFlyoutConfig>('NGX_FLYOUT_CONFIG', {\n providedIn: 'root',\n factory: () => DEFAULT_FLYOUT_CONFIG,\n});\n\n/** Settings accepted by `provideFlyout()`. Everything is optional. */\nexport interface NgxFlyoutOptions {\n closeOnConfirm?: boolean;\n hideOnBackdropClick?: boolean;\n showCloseButton?: boolean;\n showFooter?: boolean;\n animation?: FlyoutAnimation;\n labels?: Partial<FlyoutLabels>;\n}\n\n/**\n * Sets app-wide defaults for flyouts. Optional: flyouts work without it.\n *\n * ```ts\n * providers: [provideFlyout({ animation: 'slide', hideOnBackdropClick: true, labels: { confirm: 'Save' } })]\n * ```\n */\nexport function provideFlyout(options: NgxFlyoutOptions = {}): EnvironmentProviders {\n const d = DEFAULT_FLYOUT_CONFIG;\n const config: NgxFlyoutConfig = {\n closeOnConfirm: options.closeOnConfirm ?? d.closeOnConfirm,\n hideOnBackdropClick: options.hideOnBackdropClick ?? d.hideOnBackdropClick,\n showCloseButton: options.showCloseButton ?? d.showCloseButton,\n showFooter: options.showFooter ?? d.showFooter,\n animation: options.animation ?? d.animation,\n labels: { ...DEFAULT_FLYOUT_LABELS, ...options.labels },\n };\n return makeEnvironmentProviders([{ provide: NGX_FLYOUT_CONFIG, useValue: config }]);\n}\n","import { Directive } from '@angular/core';\n\n/**\n * Marks projected content shown in the icon tile next to the heading.\n * The tile only appears when this slot is used.\n *\n * ```html\n * <ngx-flyout heading=\"Project details\"><svg ngxFlyoutIcon>…</svg>Body</ngx-flyout>\n * ```\n */\n@Directive({ selector: '[ngxFlyoutIcon]' })\nexport class NgxFlyoutIcon {}\n\n/**\n * Marks projected content that replaces the built-in Cancel / OK buttons.\n *\n * ```html\n * <ngx-flyout heading=\"Share\">\n * Body\n * <div ngxFlyoutFooter><button (click)=\"flyout.close()\">Done</button></div>\n * </ngx-flyout>\n * ```\n */\n@Directive({ selector: '[ngxFlyoutFooter]' })\nexport class NgxFlyoutFooter {}\n","/**\n * Locks page scrolling while at least one flyout is open.\n * Counts locks so that closing a nested flyout keeps the page locked\n * until the last one closes.\n */\nlet lockCount = 0;\nlet saved: { overflow: string; paddingRight: string } | null = null;\n\nexport function lockScroll(doc: Document): void {\n if (lockCount++ > 0) return;\n const root = doc.documentElement;\n const win = doc.defaultView;\n // Keep the layout from jumping when the scrollbar disappears.\n const scrollbar = win ? win.innerWidth - root.clientWidth : 0;\n saved = { overflow: root.style.overflow, paddingRight: root.style.paddingRight };\n root.style.overflow = 'hidden';\n if (scrollbar > 0) {\n root.style.paddingRight = `${scrollbar}px`;\n }\n}\n\nexport function unlockScroll(doc: Document): void {\n if (lockCount === 0 || --lockCount > 0) return;\n const root = doc.documentElement;\n if (saved) {\n root.style.overflow = saved.overflow;\n root.style.paddingRight = saved.paddingRight;\n saved = null;\n }\n}\n","import { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n DestroyRef,\n ElementRef,\n PLATFORM_ID,\n booleanAttribute,\n computed,\n contentChild,\n effect,\n inject,\n input,\n model,\n output,\n untracked,\n viewChild,\n} from '@angular/core';\nimport { NGX_FLYOUT_CONFIG } from './flyout.config';\nimport { NgxFlyoutIcon } from './flyout-slots';\nimport { FlyoutCancelReason, toFlyoutAnimation } from './flyout.types';\nimport { lockScroll, unlockScroll } from './internal/scroll-lock';\n\nlet nextId = 0;\n\n/** Element ids inside one flyout, all derived from the flyout's own `id`. */\nexport interface FlyoutElementIds {\n dialog: string;\n heading: string;\n subheading: string;\n body: string;\n close: string;\n}\n\n/**\n * A side flyout that slides in from the right, over the whole app.\n * It has a heading, your projected content, and Cancel / OK buttons.\n *\n * Open it with a template reference, `[(opened)]`, or from code:\n *\n * ```html\n * <button (click)=\"flyout.open()\">Edit user</button>\n *\n * <ngx-flyout #flyout heading=\"Edit user\" (confirm)=\"save()\" (cancel)=\"discard()\">\n * <app-user-form />\n * </ngx-flyout>\n * ```\n */\n@Component({\n selector: 'ngx-flyout',\n templateUrl: './flyout.component.html',\n styleUrl: './flyout.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: { class: 'ngx-flyout-host' },\n})\nexport class NgxFlyout {\n private readonly config = inject(NGX_FLYOUT_CONFIG);\n private readonly document = inject(DOCUMENT);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n /** Whether the flyout is showing. Supports two-way binding: `[(opened)]`. */\n readonly opened = model(false);\n\n /** Heading in the header. Also used as the flyout's accessible name. */\n readonly heading = input<string>('');\n\n /** Lighter line under the heading. Leave empty to hide it. */\n readonly subheading = input<string>('');\n\n /** Text of the primary button. Default: `'OK'`, or `provideFlyout({ labels })`. */\n readonly confirmLabel = input<string>('');\n\n /** Text of the secondary button. Default: `'Cancel'`, or `provideFlyout({ labels })`. */\n readonly cancelLabel = input<string>('');\n\n /** Disables the primary button, for example while a form is invalid or saving. */\n readonly confirmDisabled = input(false, { transform: booleanAttribute });\n\n /** Show the built-in Cancel / OK footer. Turn off when your content has its own buttons. */\n readonly showFooter = input(this.config.showFooter, { transform: booleanAttribute });\n\n /** Close automatically after the primary button is clicked. Turn off to close it yourself, e.g. after saving. */\n readonly closeOnConfirm = input(this.config.closeOnConfirm, { transform: booleanAttribute });\n\n /** A click outside the panel cancels and closes the flyout. Default: `false`. */\n readonly hideOnBackdropClick = input(this.config.hideOnBackdropClick, { transform: booleanAttribute });\n\n /** Show the × button in the header. Escape still closes the flyout when it is hidden. Default: `true`. */\n readonly showCloseButton = input(this.config.showCloseButton, { transform: booleanAttribute });\n\n /**\n * `'slide'`: slides in from the right and back out on close. `'none'` (default): appears at once.\n * The slide is skipped for users who prefer reduced motion.\n */\n readonly animation = input(this.config.animation, { transform: toFlyoutAnimation });\n\n /** Id of the dialog element. Inner elements get ids derived from it. Generated when not set. */\n readonly id = input<string>(`ngx-flyout-${nextId++}`);\n\n /** The primary (OK) button was clicked. */\n readonly confirm = output<void>();\n\n /** The user dismissed the flyout: Cancel, ×, Escape, or a backdrop click (with `hideOnBackdropClick`). Not emitted by `close()`. */\n readonly cancel = output<FlyoutCancelReason>();\n\n private readonly dialog = viewChild<ElementRef<HTMLDialogElement>>('dialog');\n protected readonly projectedIcon = contentChild(NgxFlyoutIcon);\n\n protected readonly resolvedConfirmLabel = computed(\n () => this.confirmLabel() || this.config.labels.confirm,\n );\n protected readonly resolvedCancelLabel = computed(\n () => this.cancelLabel() || this.config.labels.cancel,\n );\n protected readonly closeLabel = this.config.labels.close;\n\n readonly ids = computed<FlyoutElementIds>(() => {\n const id = this.id();\n return {\n dialog: id,\n heading: `${id}-heading`,\n subheading: `${id}-subheading`,\n body: `${id}-body`,\n close: `${id}-close`,\n };\n });\n\n /** Element that had focus before opening; focus goes back to it on close. */\n private returnFocus: HTMLElement | null = null;\n private scrollLocked = false;\n /** Whether the current pointer press started on the backdrop. */\n private pressedBackdrop = false;\n\n constructor() {\n effect(() => {\n const isOpen = this.opened();\n const dialog = this.dialog()?.nativeElement;\n if (!dialog || !this.isBrowser) return;\n untracked(() => (isOpen ? this.show(dialog) : this.hide(dialog)));\n });\n\n inject(DestroyRef).onDestroy(() => this.releaseScroll());\n }\n\n /** Opens the flyout. */\n open(): void {\n this.opened.set(true);\n }\n\n /** Closes the flyout without emitting `cancel` or `confirm`. */\n close(): void {\n this.opened.set(false);\n }\n\n /** Opens the flyout when closed, closes it when open. */\n toggle(): void {\n this.opened.update((value) => !value);\n }\n\n protected onConfirm(): void {\n if (this.confirmDisabled()) return;\n this.confirm.emit();\n if (this.closeOnConfirm()) this.close();\n }\n\n protected dismiss(reason: FlyoutCancelReason): void {\n this.cancel.emit(reason);\n this.close();\n }\n\n /** Escape key: the dialog's native `cancel` event. Closing goes through `opened` instead. */\n protected onNativeCancel(event: Event): void {\n event.preventDefault();\n this.dismiss('escape');\n }\n\n /** The dialog closed on its own (e.g. a `<form method=\"dialog\">` inside it): keep `opened` in sync. */\n protected onNativeClose(): void {\n if (this.opened()) this.close();\n }\n\n protected onPointerDown(event: PointerEvent): void {\n this.pressedBackdrop = event.target === event.currentTarget;\n }\n\n /** The dialog covers the viewport; a click on the dialog itself (not the panel) is a backdrop click. */\n protected onDialogClick(event: MouseEvent): void {\n const onBackdrop = event.target === event.currentTarget && this.pressedBackdrop;\n this.pressedBackdrop = false;\n if (onBackdrop && this.hideOnBackdropClick()) this.dismiss('backdrop');\n }\n\n private show(dialog: HTMLDialogElement): void {\n if (dialog.open) return;\n const active = this.document.activeElement;\n this.returnFocus = active instanceof HTMLElement ? active : null;\n dialog.showModal();\n if (!this.scrollLocked) {\n lockScroll(this.document);\n this.scrollLocked = true;\n }\n }\n\n private hide(dialog: HTMLDialogElement): void {\n if (dialog.open) dialog.close();\n if (!this.scrollLocked) return;\n this.releaseScroll();\n const target = this.returnFocus;\n this.returnFocus = null;\n if (target?.isConnected) target.focus();\n }\n\n private releaseScroll(): void {\n if (!this.scrollLocked) return;\n unlockScroll(this.document);\n this.scrollLocked = false;\n }\n}\n","<dialog\n #dialog\n class=\"ngx-flyout\"\n [class.ngx-flyout--slide]=\"animation() === 'slide'\"\n [id]=\"ids().dialog\"\n [attr.aria-labelledby]=\"heading() ? ids().heading : null\"\n [attr.aria-describedby]=\"subheading() ? ids().subheading : null\"\n (cancel)=\"onNativeCancel($event)\"\n (close)=\"onNativeClose()\"\n (pointerdown)=\"onPointerDown($event)\"\n (click)=\"onDialogClick($event)\"\n>\n <div class=\"ngx-flyout__panel\">\n <header class=\"ngx-flyout__header\">\n @if (projectedIcon()) {\n <span class=\"ngx-flyout__icon\" aria-hidden=\"true\">\n <ng-content select=\"[ngxFlyoutIcon]\" />\n </span>\n }\n <div class=\"ngx-flyout__titles\">\n @if (heading()) {\n <h2 class=\"ngx-flyout__heading\" [id]=\"ids().heading\">{{ heading() }}</h2>\n }\n @if (subheading()) {\n <p class=\"ngx-flyout__subheading\" [id]=\"ids().subheading\">{{ subheading() }}</p>\n }\n </div>\n @if (showCloseButton()) {\n <button\n type=\"button\"\n class=\"ngx-flyout__close\"\n [id]=\"ids().close\"\n [attr.aria-label]=\"closeLabel\"\n [attr.title]=\"closeLabel\"\n (click)=\"dismiss('close')\"\n >\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </svg>\n </button>\n }\n </header>\n\n <div class=\"ngx-flyout__body\" [id]=\"ids().body\">\n <ng-content />\n </div>\n\n @if (showFooter()) {\n <footer class=\"ngx-flyout__footer\">\n <ng-content select=\"[ngxFlyoutFooter]\">\n <button type=\"button\" class=\"ngx-flyout__btn ngx-flyout__btn--secondary\" (click)=\"dismiss('button')\">\n {{ resolvedCancelLabel() }}\n </button>\n <button\n type=\"button\"\n class=\"ngx-flyout__btn ngx-flyout__btn--primary\"\n [disabled]=\"confirmDisabled()\"\n (click)=\"onConfirm()\"\n >\n {{ resolvedConfirmLabel() }}\n </button>\n </ng-content>\n </footer>\n }\n </div>\n</dialog>\n","/*\n * Public API Surface of ngx-flyout\n */\n\nexport * from './lib/flyout.types';\nexport * from './lib/flyout.config';\nexport * from './lib/flyout-slots';\nexport * from './lib/flyout.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAkBA;AACM,SAAU,iBAAiB,CAAC,KAAmD,EAAA;AACnF,IAAA,OAAO,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,IAAI,GAAG,OAAO,GAAG,MAAM;AAC/D;;ACFO,MAAM,qBAAqB,GAAiB;AACjD,IAAA,OAAO,EAAE,IAAI;AACb,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,KAAK,EAA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,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,EC1G/D,42EA2EA,EAAA,MAAA,EAAA,CAAA,63HAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;4FDpBa,SAAS,EAAA,UAAA,EAAA,CAAA;kBAPrB,SAAS;+BACE,YAAY,EAAA,eAAA,EAGL,uBAAuB,CAAC,MAAM,QACzC,EAAE,KAAK,EAAE,iBAAiB,EAAE,EAAA,QAAA,EAAA,42EAAA,EAAA,MAAA,EAAA,CAAA,63HAAA,CAAA,EAAA;;;AErDpC;;AAEG;;ACFH;;AAEG;;;;"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
/**
|
|
3
|
+
* Marks projected content shown in the icon tile next to the heading.
|
|
4
|
+
* The tile only appears when this slot is used.
|
|
5
|
+
*
|
|
6
|
+
* ```html
|
|
7
|
+
* <ngx-flyout heading="Project details"><svg ngxFlyoutIcon>…</svg>Body</ngx-flyout>
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
export declare class NgxFlyoutIcon {
|
|
11
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NgxFlyoutIcon, never>;
|
|
12
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<NgxFlyoutIcon, "[ngxFlyoutIcon]", never, {}, {}, never, never, true, never>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Marks projected content that replaces the built-in Cancel / OK buttons.
|
|
16
|
+
*
|
|
17
|
+
* ```html
|
|
18
|
+
* <ngx-flyout heading="Share">
|
|
19
|
+
* Body
|
|
20
|
+
* <div ngxFlyoutFooter><button (click)="flyout.close()">Done</button></div>
|
|
21
|
+
* </ngx-flyout>
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare class NgxFlyoutFooter {
|
|
25
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NgxFlyoutFooter, never>;
|
|
26
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<NgxFlyoutFooter, "[ngxFlyoutFooter]", never, {}, {}, never, never, true, never>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { NgxFlyoutIcon } from './flyout-slots';
|
|
2
|
+
import { FlyoutCancelReason } from './flyout.types';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/** Element ids inside one flyout, all derived from the flyout's own `id`. */
|
|
5
|
+
export interface FlyoutElementIds {
|
|
6
|
+
dialog: string;
|
|
7
|
+
heading: string;
|
|
8
|
+
subheading: string;
|
|
9
|
+
body: string;
|
|
10
|
+
close: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A side flyout that slides in from the right, over the whole app.
|
|
14
|
+
* It has a heading, your projected content, and Cancel / OK buttons.
|
|
15
|
+
*
|
|
16
|
+
* Open it with a template reference, `[(opened)]`, or from code:
|
|
17
|
+
*
|
|
18
|
+
* ```html
|
|
19
|
+
* <button (click)="flyout.open()">Edit user</button>
|
|
20
|
+
*
|
|
21
|
+
* <ngx-flyout #flyout heading="Edit user" (confirm)="save()" (cancel)="discard()">
|
|
22
|
+
* <app-user-form />
|
|
23
|
+
* </ngx-flyout>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class NgxFlyout {
|
|
27
|
+
private readonly config;
|
|
28
|
+
private readonly document;
|
|
29
|
+
private readonly isBrowser;
|
|
30
|
+
/** Whether the flyout is showing. Supports two-way binding: `[(opened)]`. */
|
|
31
|
+
readonly opened: import("@angular/core").ModelSignal<boolean>;
|
|
32
|
+
/** Heading in the header. Also used as the flyout's accessible name. */
|
|
33
|
+
readonly heading: import("@angular/core").InputSignal<string>;
|
|
34
|
+
/** Lighter line under the heading. Leave empty to hide it. */
|
|
35
|
+
readonly subheading: import("@angular/core").InputSignal<string>;
|
|
36
|
+
/** Text of the primary button. Default: `'OK'`, or `provideFlyout({ labels })`. */
|
|
37
|
+
readonly confirmLabel: import("@angular/core").InputSignal<string>;
|
|
38
|
+
/** Text of the secondary button. Default: `'Cancel'`, or `provideFlyout({ labels })`. */
|
|
39
|
+
readonly cancelLabel: import("@angular/core").InputSignal<string>;
|
|
40
|
+
/** Disables the primary button, for example while a form is invalid or saving. */
|
|
41
|
+
readonly confirmDisabled: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
42
|
+
/** Show the built-in Cancel / OK footer. Turn off when your content has its own buttons. */
|
|
43
|
+
readonly showFooter: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
44
|
+
/** Close automatically after the primary button is clicked. Turn off to close it yourself, e.g. after saving. */
|
|
45
|
+
readonly closeOnConfirm: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
46
|
+
/** A click outside the panel cancels and closes the flyout. Default: `false`. */
|
|
47
|
+
readonly hideOnBackdropClick: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
48
|
+
/** Show the × button in the header. Escape still closes the flyout when it is hidden. Default: `true`. */
|
|
49
|
+
readonly showCloseButton: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
50
|
+
/**
|
|
51
|
+
* `'slide'`: slides in from the right and back out on close. `'none'` (default): appears at once.
|
|
52
|
+
* The slide is skipped for users who prefer reduced motion.
|
|
53
|
+
*/
|
|
54
|
+
readonly animation: import("@angular/core").InputSignalWithTransform<import("ngx-flyout").FlyoutAnimation, boolean | import("ngx-flyout").FlyoutAnimation | null | undefined>;
|
|
55
|
+
/** Id of the dialog element. Inner elements get ids derived from it. Generated when not set. */
|
|
56
|
+
readonly id: import("@angular/core").InputSignal<string>;
|
|
57
|
+
/** The primary (OK) button was clicked. */
|
|
58
|
+
readonly confirm: import("@angular/core").OutputEmitterRef<void>;
|
|
59
|
+
/** The user dismissed the flyout: Cancel, ×, Escape, or a backdrop click (with `hideOnBackdropClick`). Not emitted by `close()`. */
|
|
60
|
+
readonly cancel: import("@angular/core").OutputEmitterRef<FlyoutCancelReason>;
|
|
61
|
+
private readonly dialog;
|
|
62
|
+
protected readonly projectedIcon: import("@angular/core").Signal<NgxFlyoutIcon | undefined>;
|
|
63
|
+
protected readonly resolvedConfirmLabel: import("@angular/core").Signal<string>;
|
|
64
|
+
protected readonly resolvedCancelLabel: import("@angular/core").Signal<string>;
|
|
65
|
+
protected readonly closeLabel: string;
|
|
66
|
+
readonly ids: import("@angular/core").Signal<FlyoutElementIds>;
|
|
67
|
+
/** Element that had focus before opening; focus goes back to it on close. */
|
|
68
|
+
private returnFocus;
|
|
69
|
+
private scrollLocked;
|
|
70
|
+
/** Whether the current pointer press started on the backdrop. */
|
|
71
|
+
private pressedBackdrop;
|
|
72
|
+
constructor();
|
|
73
|
+
/** Opens the flyout. */
|
|
74
|
+
open(): void;
|
|
75
|
+
/** Closes the flyout without emitting `cancel` or `confirm`. */
|
|
76
|
+
close(): void;
|
|
77
|
+
/** Opens the flyout when closed, closes it when open. */
|
|
78
|
+
toggle(): void;
|
|
79
|
+
protected onConfirm(): void;
|
|
80
|
+
protected dismiss(reason: FlyoutCancelReason): void;
|
|
81
|
+
/** Escape key: the dialog's native `cancel` event. Closing goes through `opened` instead. */
|
|
82
|
+
protected onNativeCancel(event: Event): void;
|
|
83
|
+
/** The dialog closed on its own (e.g. a `<form method="dialog">` inside it): keep `opened` in sync. */
|
|
84
|
+
protected onNativeClose(): void;
|
|
85
|
+
protected onPointerDown(event: PointerEvent): void;
|
|
86
|
+
/** The dialog covers the viewport; a click on the dialog itself (not the panel) is a backdrop click. */
|
|
87
|
+
protected onDialogClick(event: MouseEvent): void;
|
|
88
|
+
private show;
|
|
89
|
+
private hide;
|
|
90
|
+
private releaseScroll;
|
|
91
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NgxFlyout, never>;
|
|
92
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NgxFlyout, "ngx-flyout", never, { "opened": { "alias": "opened"; "required": false; "isSignal": true; }; "heading": { "alias": "heading"; "required": false; "isSignal": true; }; "subheading": { "alias": "subheading"; "required": false; "isSignal": true; }; "confirmLabel": { "alias": "confirmLabel"; "required": false; "isSignal": true; }; "cancelLabel": { "alias": "cancelLabel"; "required": false; "isSignal": true; }; "confirmDisabled": { "alias": "confirmDisabled"; "required": false; "isSignal": true; }; "showFooter": { "alias": "showFooter"; "required": false; "isSignal": true; }; "closeOnConfirm": { "alias": "closeOnConfirm"; "required": false; "isSignal": true; }; "hideOnBackdropClick": { "alias": "hideOnBackdropClick"; "required": false; "isSignal": true; }; "showCloseButton": { "alias": "showCloseButton"; "required": false; "isSignal": true; }; "animation": { "alias": "animation"; "required": false; "isSignal": true; }; "id": { "alias": "id"; "required": false; "isSignal": true; }; }, { "opened": "openedChange"; "confirm": "confirm"; "cancel": "cancel"; }, ["projectedIcon"], ["[ngxFlyoutIcon]", "*", "[ngxFlyoutFooter]"], true, never>;
|
|
93
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { EnvironmentProviders, InjectionToken } from '@angular/core';
|
|
2
|
+
import { FlyoutAnimation, FlyoutLabels } from './flyout.types';
|
|
3
|
+
/** App-wide settings for every `<ngx-flyout>`. */
|
|
4
|
+
export interface NgxFlyoutConfig {
|
|
5
|
+
/** Default for the `closeOnConfirm` input. Default: `true`. */
|
|
6
|
+
closeOnConfirm: boolean;
|
|
7
|
+
/** Default for the `hideOnBackdropClick` input. Default: `false`. */
|
|
8
|
+
hideOnBackdropClick: boolean;
|
|
9
|
+
/** Default for the `showCloseButton` input. Default: `true`. */
|
|
10
|
+
showCloseButton: boolean;
|
|
11
|
+
/** Default for the `showFooter` input. Default: `true`. */
|
|
12
|
+
showFooter: boolean;
|
|
13
|
+
/** Default for the `animation` input. Default: `'none'`. */
|
|
14
|
+
animation: FlyoutAnimation;
|
|
15
|
+
/** Default button text. Override these to translate them. */
|
|
16
|
+
labels: FlyoutLabels;
|
|
17
|
+
}
|
|
18
|
+
export declare const DEFAULT_FLYOUT_LABELS: FlyoutLabels;
|
|
19
|
+
export declare const DEFAULT_FLYOUT_CONFIG: NgxFlyoutConfig;
|
|
20
|
+
export declare const NGX_FLYOUT_CONFIG: InjectionToken<NgxFlyoutConfig>;
|
|
21
|
+
/** Settings accepted by `provideFlyout()`. Everything is optional. */
|
|
22
|
+
export interface NgxFlyoutOptions {
|
|
23
|
+
closeOnConfirm?: boolean;
|
|
24
|
+
hideOnBackdropClick?: boolean;
|
|
25
|
+
showCloseButton?: boolean;
|
|
26
|
+
showFooter?: boolean;
|
|
27
|
+
animation?: FlyoutAnimation;
|
|
28
|
+
labels?: Partial<FlyoutLabels>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Sets app-wide defaults for flyouts. Optional: flyouts work without it.
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* providers: [provideFlyout({ animation: 'slide', hideOnBackdropClick: true, labels: { confirm: 'Save' } })]
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function provideFlyout(options?: NgxFlyoutOptions): EnvironmentProviders;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How the user dismissed the flyout, passed with the `cancel` output.
|
|
3
|
+
*
|
|
4
|
+
* - `button`: the footer's Cancel button
|
|
5
|
+
* - `close`: the × button in the header
|
|
6
|
+
* - `escape`: the Escape key
|
|
7
|
+
* - `backdrop`: a click outside the panel (only when `hideOnBackdropClick` is on)
|
|
8
|
+
*/
|
|
9
|
+
export type FlyoutCancelReason = 'button' | 'close' | 'escape' | 'backdrop';
|
|
10
|
+
/**
|
|
11
|
+
* How the flyout opens and closes.
|
|
12
|
+
*
|
|
13
|
+
* - `none`: it appears and disappears at once (default)
|
|
14
|
+
* - `slide`: it slides in from the right and back out again
|
|
15
|
+
*/
|
|
16
|
+
export type FlyoutAnimation = 'none' | 'slide';
|
|
17
|
+
/** Input transform for `animation`: also accepts `true` (slide) and `false` / `null` (none). */
|
|
18
|
+
export declare function toFlyoutAnimation(value: FlyoutAnimation | boolean | null | undefined): FlyoutAnimation;
|
|
19
|
+
/** Default text for the built-in buttons. Override these to translate them. */
|
|
20
|
+
export interface FlyoutLabels {
|
|
21
|
+
/** Primary footer button. */
|
|
22
|
+
confirm: string;
|
|
23
|
+
/** Secondary footer button. */
|
|
24
|
+
cancel: string;
|
|
25
|
+
/** Screen-reader name of the × button. */
|
|
26
|
+
close: string;
|
|
27
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ngx-flyout",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Accessible side flyout (drawer) for Angular 19+: a heading, your content, and OK / Cancel actions, built on the native dialog element with zero dependencies.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"angular",
|
|
7
|
+
"ngx",
|
|
8
|
+
"flyout",
|
|
9
|
+
"drawer",
|
|
10
|
+
"side-panel",
|
|
11
|
+
"sheet",
|
|
12
|
+
"dialog",
|
|
13
|
+
"modal",
|
|
14
|
+
"accessible",
|
|
15
|
+
"a11y",
|
|
16
|
+
"standalone",
|
|
17
|
+
"signals"
|
|
18
|
+
],
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"author": "Vishal Sharma",
|
|
21
|
+
"homepage": "https://github.com/vishaalsharmaa/ngx-flyout#readme",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/vishaalsharmaa/ngx-flyout.git"
|
|
25
|
+
},
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/vishaalsharmaa/ngx-flyout/issues"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@angular/common": ">=19.0.0 <22.0.0",
|
|
31
|
+
"@angular/core": ">=19.0.0 <22.0.0"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"tslib": "^2.3.0"
|
|
35
|
+
},
|
|
36
|
+
"sideEffects": false,
|
|
37
|
+
"module": "fesm2022/ngx-flyout.mjs",
|
|
38
|
+
"typings": "index.d.ts",
|
|
39
|
+
"exports": {
|
|
40
|
+
"./package.json": {
|
|
41
|
+
"default": "./package.json"
|
|
42
|
+
},
|
|
43
|
+
".": {
|
|
44
|
+
"types": "./index.d.ts",
|
|
45
|
+
"default": "./fesm2022/ngx-flyout.mjs"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
6
48
|
}
|
package/public-api.d.ts
ADDED