ng-sidebar9plus 12.0.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/LICENSE +21 -0
- package/README.md +240 -0
- package/lib_commonjs/close.directive.d.ts +9 -0
- package/lib_commonjs/close.directive.js +32 -0
- package/lib_commonjs/index.d.ts +4 -0
- package/lib_commonjs/index.js +11 -0
- package/lib_commonjs/sidebar-container.component.d.ts +29 -0
- package/lib_commonjs/sidebar-container.component.js +207 -0
- package/lib_commonjs/sidebar.component.d.ts +86 -0
- package/lib_commonjs/sidebar.component.js +550 -0
- package/lib_commonjs/sidebar.module.d.ts +12 -0
- package/lib_commonjs/sidebar.module.js +32 -0
- package/lib_commonjs/utils.d.ts +2 -0
- package/lib_commonjs/utils.js +23 -0
- package/lib_esmodule/close.directive.js +29 -0
- package/lib_esmodule/index.js +4 -0
- package/lib_esmodule/sidebar-container.component.js +204 -0
- package/lib_esmodule/sidebar.component.js +547 -0
- package/lib_esmodule/sidebar.module.js +29 -0
- package/lib_esmodule/utils.js +18 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 - present Eugene Cheung
|
|
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
|
|
13
|
+
all 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
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# ng-sidebar9plus
|
|
2
|
+
|
|
3
|
+
⚠️ **This package is forked form deprecated package **[ng-sidebar](https://www.npmjs.com/package/ng-sidebar)** .** ⚠️
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
[](https://nodei.co/npm/ng-sidebar)
|
|
8
|
+
|
|
9
|
+
**[Demo](https://echeung.me/ng-sidebar)**
|
|
10
|
+
|
|
11
|
+
*Formerly called [ng-sidebar](https://github.com/arkon/ng-sidebar)*
|
|
12
|
+
|
|
13
|
+
An Angular sidebar component.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```shell
|
|
19
|
+
npm install --save ng-sidebar9plus
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### SystemJS configuration
|
|
23
|
+
|
|
24
|
+
If you're using SystemJS, be sure to add the appropriate settings to your SystemJS config:
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
const map = {
|
|
28
|
+
// ...
|
|
29
|
+
'ng-sidebar9plus': 'node_modules/ng-sidebar9plus',
|
|
30
|
+
// ...
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const packages = {
|
|
34
|
+
// ...
|
|
35
|
+
'ng-sidebar9plus': {
|
|
36
|
+
main: 'lib/index',
|
|
37
|
+
defaultExtension: 'js'
|
|
38
|
+
},
|
|
39
|
+
// ...
|
|
40
|
+
};
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## Changelog
|
|
45
|
+
|
|
46
|
+
See the [releases page](https://github.com/arkon/ng-sidebar/releases) on GitHub.
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
Add `SidebarModule` to your app module:
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import { SidebarModule } from 'ng-sidebar';
|
|
55
|
+
|
|
56
|
+
@NgModule({
|
|
57
|
+
declarations: [AppComponent],
|
|
58
|
+
imports: [BrowserModule, SidebarModule.forRoot()],
|
|
59
|
+
bootstrap: [AppComponent],
|
|
60
|
+
})
|
|
61
|
+
class AppModule {}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
In your app component, simply use add a `<ng-sidebar-container>` wrapper, then place your `<ng-sidebar>`(s) and content within it.
|
|
65
|
+
Your page content should be in some container with a `ng-sidebar-content` attribute.
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
@Component({
|
|
69
|
+
selector: 'app',
|
|
70
|
+
template: `
|
|
71
|
+
<!-- Container for sidebar(s) + page content -->
|
|
72
|
+
<ng-sidebar-container>
|
|
73
|
+
|
|
74
|
+
<!-- A sidebar -->
|
|
75
|
+
<ng-sidebar [(opened)]="_opened">
|
|
76
|
+
<p>Sidebar contents</p>
|
|
77
|
+
</ng-sidebar>
|
|
78
|
+
|
|
79
|
+
<!-- Page content -->
|
|
80
|
+
<div ng-sidebar-content>
|
|
81
|
+
<button (click)="_toggleSidebar()">Toggle sidebar</button>
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
</ng-sidebar-container>
|
|
85
|
+
`
|
|
86
|
+
})
|
|
87
|
+
class AppComponent {
|
|
88
|
+
private _opened: boolean = false;
|
|
89
|
+
|
|
90
|
+
private _toggleSidebar() {
|
|
91
|
+
this._opened = !this._opened;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
If nothing seems to show up, your wrappers' heights may be collapsing. Try adding a height (e.g. `height: 100vh;`) to the wrapper `<ng-sidebar-container>` or other wrapper elements you may have. (See [issue #100](https://github.com/arkon/ng-sidebar/issues/100) for more info.)
|
|
97
|
+
|
|
98
|
+
A directive is also provided to easily close the sidebar by clicking something inside it:
|
|
99
|
+
|
|
100
|
+
```html
|
|
101
|
+
<ng-sidebar>
|
|
102
|
+
<a closeSidebar>Closes the sidebar</a>
|
|
103
|
+
</ng-sidebar>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
You can also use the `open()` and `close()` functions:
|
|
107
|
+
|
|
108
|
+
```html
|
|
109
|
+
<ng-sidebar #sidebar>
|
|
110
|
+
<button (click)="sidebar.close()">Close sidebar</button>
|
|
111
|
+
</ng-sidebar>
|
|
112
|
+
|
|
113
|
+
<button (click)="sidebar.open()">Open sidebar</button>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
## Functions
|
|
118
|
+
|
|
119
|
+
The sidebar has a few public functions:
|
|
120
|
+
|
|
121
|
+
| Function | Description |
|
|
122
|
+
| -------- | ----------- |
|
|
123
|
+
| `open()` | Opens the sidebar. |
|
|
124
|
+
| `close()` | Closes the sidebar. |
|
|
125
|
+
| `triggerRerender()` | Manually trigger a re-render of the container. Useful if the sidebar contents might change. |
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
## Styling
|
|
129
|
+
|
|
130
|
+
Various class names are attached to the sidebar and container for easier styling.
|
|
131
|
+
|
|
132
|
+
If you are using Angular's default emulated view encapsulation, you may have to use the `>>>` selector to target the sidebar's classes. Check out [Angular's documentation](https://angular.io/guide/component-styles#deep) for more details. Note that the `/deep/` selector [will soon be deprecated](https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/68qSZM5QMRQ/pT2YCqZSomAJ).
|
|
133
|
+
|
|
134
|
+
### Sidebar
|
|
135
|
+
|
|
136
|
+
| Class name | Description |
|
|
137
|
+
| ---------- | ----------- |
|
|
138
|
+
| `ng-sidebar` | Always on the sidebar element. |
|
|
139
|
+
| `ng-sidebar--opened` | When `opened` is `true`. |
|
|
140
|
+
| `ng-sidebar--closed` | When `opened` is `false`. |
|
|
141
|
+
| `ng-sidebar--left` | When `position` is `'left'` (or the `'start'`/`'end'` aliases are equivalent to `'left'`). |
|
|
142
|
+
| `ng-sidebar--right` | When `position` is `'right'` (or the `'start'`/`'end'` aliases are equivalent to `'right'`). |
|
|
143
|
+
| `ng-sidebar--top` | When `position` is `'top'`. |
|
|
144
|
+
| `ng-sidebar--bottom` | When `position` is `'bottom'`. |
|
|
145
|
+
| `ng-sidebar--over` | When `mode` is `'over'`. |
|
|
146
|
+
| `ng-sidebar--push` | When `mode` is `'push'`. |
|
|
147
|
+
| `ng-sidebar--slide` | When `mode` is `'slide'`. |
|
|
148
|
+
| `ng-sidebar--docked` | When the sidebar is docked (i.e. it is "closed" and `dock` is `true`). |
|
|
149
|
+
| `ng-sidebar--inert` | Ignores pointer clicks. Class is applied when the sidebar is closed. |
|
|
150
|
+
| `ng-sidebar--animate` | When `animate` is `true` for a sidebar. |
|
|
151
|
+
|
|
152
|
+
### Backdrop
|
|
153
|
+
|
|
154
|
+
| Class name | Description |
|
|
155
|
+
| ---------- | ----------- |
|
|
156
|
+
| `ng-sidebar__backdrop` | Class of the backdrop `div`. Note that the `div` is only in the DOM when the backdrop is shown. |
|
|
157
|
+
|
|
158
|
+
### Page content
|
|
159
|
+
|
|
160
|
+
| Class name | Description |
|
|
161
|
+
| ---------- | ----------- |
|
|
162
|
+
| `ng-sidebar__content` | Class of the wrapper `div` for the page content. |
|
|
163
|
+
| `ng-sidebar__content--animate` | When `animate` is `true` for the container. |
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
## Options
|
|
168
|
+
|
|
169
|
+
### `<ng-sidebar-container>`
|
|
170
|
+
|
|
171
|
+
### Inputs
|
|
172
|
+
|
|
173
|
+
| Property name | Type | Default | Description |
|
|
174
|
+
| ------------- | ---- | ------- | ----------- |
|
|
175
|
+
| contentClass | string | | Additional class name on the `div` wrapping the page contents. |
|
|
176
|
+
| backdropClass | string | | Additional class name on the overlay element. |
|
|
177
|
+
| showBackdrop | boolean | `false` | Controls the backdrop state of the sidebar container. This should be two-way bound. |
|
|
178
|
+
| allowSidebarBackdropControl | boolean | `true` | Determines if the container component respects the sidebar's `showBackdrop` input option. |
|
|
179
|
+
| animate | boolean | `true` | Animates the container sliding. |
|
|
180
|
+
|
|
181
|
+
#### Outputs
|
|
182
|
+
|
|
183
|
+
| Property name | Callback arguments | Description |
|
|
184
|
+
| ------------- | ------------------ | ----------- |
|
|
185
|
+
| showBackdropChange | `showBackdrop: boolean` | Emitted when `showBackdrop` is modified. This allows for you to do "two-way binding" (i.e. `[(showBackdrop)]`). |
|
|
186
|
+
| onBackdropClicked | | Emitted when a backdrop is clicked. |
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
### `<ng-sidebar>`
|
|
190
|
+
|
|
191
|
+
#### Inputs
|
|
192
|
+
|
|
193
|
+
| Property name | Type | Default | Description |
|
|
194
|
+
| ------------- | ---- | ------- | ----------- |
|
|
195
|
+
| opened | boolean | `false` | Controls the opened state of the sidebar. This should be two-way bound. |
|
|
196
|
+
| mode | `'over'`, `'push'`, `'slide'` | `'over'` | See the "Modes" section. |
|
|
197
|
+
| dock | boolean | `false` | Show the sidebar as docked when closed. |
|
|
198
|
+
| dockedSize | string | `'0px'` | When `mode` is set to `'dock'`, this value indicates how much of the sidebar is still visible when "closed". |
|
|
199
|
+
| position | `'left'`, `'right'`, `'top'`, `'bottom'`, `'start'`, `'end'` | `'start'` | What side the sidebar should be docked to. `'start'` and `'end'` are aliases that respect the page's language (e.g. `start` is the same as `left` for English, but would be `right` for Hebrew. |
|
|
200
|
+
| autoCollapseHeight | number | | Window height in pixels in which to automatically close the sidebar. |
|
|
201
|
+
| autoCollapseWidth | number | | Window width in pixels in which to automatically close the sidebar. |
|
|
202
|
+
| autoCollapseOnInit | boolean | `true` | Collapse sidebar based on `autoCollapseHeight` and/or `autoCollapseWidth` on initial render as needed. |
|
|
203
|
+
| animate | boolean | `true` | Animate the opening/closing of the sidebar. |
|
|
204
|
+
| sidebarClass | string | | Additional class name on the sidebar element. |
|
|
205
|
+
| ariaLabel | string | | Value for the sidebar's `aria-label` attribute. |
|
|
206
|
+
| trapFocus | boolean | `false` | Keeps focus within the sidebar when open. Note that this only works if there's one sidebar open at a time. |
|
|
207
|
+
| autoFocus | boolean | `true` | Automatically focus the first focusable element in the sidebar when opened. |
|
|
208
|
+
| showBackdrop | boolean | `false` | If a translucent black backdrop overlay should appear over the page contents when the sidebar is opened. This is ignored if the sidebar's parent container has its `allowSidebarBackdropControl` property set to `true`. |
|
|
209
|
+
| closeOnClickBackdrop | boolean | `false` | Whether clicking on the backdrop of the open sidebar will close it. |
|
|
210
|
+
| closeOnClickOutside | boolean | `false` | Whether clicking outside of the open sidebar will close it. |
|
|
211
|
+
| keyClose | boolean | `false` | Close the sidebar when a keyboard button is pressed. |
|
|
212
|
+
| keyCode | number | `27` | The [key code](http://keycode.info/) for `keyClose`. |
|
|
213
|
+
|
|
214
|
+
#### Outputs
|
|
215
|
+
|
|
216
|
+
| Property name | Callback arguments | Description |
|
|
217
|
+
| ------------- | ------------------ | ----------- |
|
|
218
|
+
| onContentInit | | Corresponds with `ngAfterContentInit` lifecycle event of the sidebar component. |
|
|
219
|
+
| openedChange | `opened: boolean` | Emitted when `opened` is modified. This allows for you to do "two-way binding" (i.e. `[(opened)]`). |
|
|
220
|
+
| onOpenStart | | Emitted when the sidebar is opening. |
|
|
221
|
+
| onOpened | | Emitted when the sidebar is opened. |
|
|
222
|
+
| onCloseStart | | Emitted when the sidebar is closing. |
|
|
223
|
+
| onClosed | | Emitted when the sidebar is closed. |
|
|
224
|
+
| onTransitionEnd | | Emitted when the animation for opening or closing ends. |
|
|
225
|
+
| onModeChange | `mode: string` | Emitted when `mode` is changed. |
|
|
226
|
+
| onPositionChange | `position: string` | Emitted when `position` is changed. |
|
|
227
|
+
|
|
228
|
+
#### Modes
|
|
229
|
+
|
|
230
|
+
##### `over`
|
|
231
|
+
|
|
232
|
+
This is the default mode. The sidebar slides in over the page contents.
|
|
233
|
+
|
|
234
|
+
##### `push`
|
|
235
|
+
|
|
236
|
+
The page contents is pushed to make space for the sidebar.
|
|
237
|
+
|
|
238
|
+
##### `slide`
|
|
239
|
+
|
|
240
|
+
The entire page slides over to show the sidebar. Note that this only works if you have one sidebar open at a time.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Sidebar } from './sidebar.component';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class CloseSidebar {
|
|
4
|
+
private _sidebar;
|
|
5
|
+
constructor(_sidebar: Sidebar);
|
|
6
|
+
_onClick(): void;
|
|
7
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CloseSidebar, never>;
|
|
8
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<CloseSidebar, "[closeSidebar]", never, {}, {}, never>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloseSidebar = void 0;
|
|
4
|
+
var core_1 = require("@angular/core");
|
|
5
|
+
var sidebar_component_1 = require("./sidebar.component");
|
|
6
|
+
var i0 = require("@angular/core");
|
|
7
|
+
var i1 = require("./sidebar.component");
|
|
8
|
+
var CloseSidebar = (function () {
|
|
9
|
+
function CloseSidebar(_sidebar) {
|
|
10
|
+
this._sidebar = _sidebar;
|
|
11
|
+
}
|
|
12
|
+
CloseSidebar.prototype._onClick = function () {
|
|
13
|
+
if (this._sidebar) {
|
|
14
|
+
this._sidebar.close();
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
CloseSidebar.ɵfac = function CloseSidebar_Factory(t) { return new (t || CloseSidebar)(i0.ɵɵdirectiveInject(i1.Sidebar)); };
|
|
18
|
+
CloseSidebar.ɵdir = i0.ɵɵdefineDirective({ type: CloseSidebar, selectors: [["", "closeSidebar", ""]], hostBindings: function CloseSidebar_HostBindings(rf, ctx) { if (rf & 1) {
|
|
19
|
+
i0.ɵɵlistener("click", function CloseSidebar_click_HostBindingHandler() { return ctx._onClick(); });
|
|
20
|
+
} } });
|
|
21
|
+
return CloseSidebar;
|
|
22
|
+
}());
|
|
23
|
+
exports.CloseSidebar = CloseSidebar;
|
|
24
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CloseSidebar, [{
|
|
25
|
+
type: core_1.Directive,
|
|
26
|
+
args: [{
|
|
27
|
+
selector: '[closeSidebar]',
|
|
28
|
+
host: {
|
|
29
|
+
'(click)': '_onClick()'
|
|
30
|
+
}
|
|
31
|
+
}]
|
|
32
|
+
}], function () { return [{ type: i1.Sidebar }]; }, null); })();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SidebarModule = exports.CloseSidebar = exports.Sidebar = exports.SidebarContainer = void 0;
|
|
4
|
+
var sidebar_container_component_1 = require("./sidebar-container.component");
|
|
5
|
+
Object.defineProperty(exports, "SidebarContainer", { enumerable: true, get: function () { return sidebar_container_component_1.SidebarContainer; } });
|
|
6
|
+
var sidebar_component_1 = require("./sidebar.component");
|
|
7
|
+
Object.defineProperty(exports, "Sidebar", { enumerable: true, get: function () { return sidebar_component_1.Sidebar; } });
|
|
8
|
+
var close_directive_1 = require("./close.directive");
|
|
9
|
+
Object.defineProperty(exports, "CloseSidebar", { enumerable: true, get: function () { return close_directive_1.CloseSidebar; } });
|
|
10
|
+
var sidebar_module_1 = require("./sidebar.module");
|
|
11
|
+
Object.defineProperty(exports, "SidebarModule", { enumerable: true, get: function () { return sidebar_module_1.SidebarModule; } });
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AfterContentInit, ChangeDetectorRef, EventEmitter, OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
|
|
2
|
+
import { Sidebar } from './sidebar.component';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare class SidebarContainer implements AfterContentInit, OnChanges, OnDestroy {
|
|
5
|
+
private _ref;
|
|
6
|
+
animate: boolean;
|
|
7
|
+
allowSidebarBackdropControl: boolean;
|
|
8
|
+
showBackdrop: boolean;
|
|
9
|
+
showBackdropChange: EventEmitter<boolean>;
|
|
10
|
+
onBackdropClicked: EventEmitter<null>;
|
|
11
|
+
contentClass: string;
|
|
12
|
+
backdropClass: string;
|
|
13
|
+
private _sidebars;
|
|
14
|
+
private _isBrowser;
|
|
15
|
+
constructor(_ref: ChangeDetectorRef, platformId: Object);
|
|
16
|
+
ngAfterContentInit(): void;
|
|
17
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
18
|
+
ngOnDestroy(): void;
|
|
19
|
+
_addSidebar(sidebar: Sidebar): void;
|
|
20
|
+
_removeSidebar(sidebar: Sidebar): void;
|
|
21
|
+
_getContentStyle(): CSSStyleDeclaration;
|
|
22
|
+
_onBackdropClicked(): void;
|
|
23
|
+
private _subscribe;
|
|
24
|
+
private _unsubscribe;
|
|
25
|
+
private _onToggle;
|
|
26
|
+
private _markForCheck;
|
|
27
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SidebarContainer, never>;
|
|
28
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SidebarContainer, "ng-sidebar-container", never, { "animate": "animate"; "allowSidebarBackdropControl": "allowSidebarBackdropControl"; "showBackdrop": "showBackdrop"; "contentClass": "contentClass"; "backdropClass": "backdropClass"; }, { "showBackdropChange": "showBackdropChange"; "onBackdropClicked": "onBackdropClicked"; }, never, ["ng-sidebar,[ng-sidebar]", "[ng-sidebar-content]"]>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SidebarContainer = void 0;
|
|
4
|
+
var core_1 = require("@angular/core");
|
|
5
|
+
var common_1 = require("@angular/common");
|
|
6
|
+
var i0 = require("@angular/core");
|
|
7
|
+
var i1 = require("@angular/common");
|
|
8
|
+
function SidebarContainer_div_0_Template(rf, ctx) { if (rf & 1) {
|
|
9
|
+
var _r2 = i0.ɵɵgetCurrentView();
|
|
10
|
+
i0.ɵɵelementStart(0, "div", 2);
|
|
11
|
+
i0.ɵɵlistener("click", function SidebarContainer_div_0_Template_div_click_0_listener() { i0.ɵɵrestoreView(_r2); var ctx_r1 = i0.ɵɵnextContext(); return ctx_r1._onBackdropClicked(); });
|
|
12
|
+
i0.ɵɵelementEnd();
|
|
13
|
+
} if (rf & 2) {
|
|
14
|
+
var ctx_r0 = i0.ɵɵnextContext();
|
|
15
|
+
i0.ɵɵproperty("ngClass", ctx_r0.backdropClass);
|
|
16
|
+
} }
|
|
17
|
+
var _c0 = [[["ng-sidebar"], ["", "ng-sidebar", ""]], [["", "ng-sidebar-content", ""]]];
|
|
18
|
+
var _c1 = ["ng-sidebar,[ng-sidebar]", "[ng-sidebar-content]"];
|
|
19
|
+
var SidebarContainer = (function () {
|
|
20
|
+
function SidebarContainer(_ref, platformId) {
|
|
21
|
+
this._ref = _ref;
|
|
22
|
+
this.animate = true;
|
|
23
|
+
this.allowSidebarBackdropControl = true;
|
|
24
|
+
this.showBackdrop = false;
|
|
25
|
+
this.showBackdropChange = new core_1.EventEmitter();
|
|
26
|
+
this.onBackdropClicked = new core_1.EventEmitter();
|
|
27
|
+
this._sidebars = [];
|
|
28
|
+
this._isBrowser = common_1.isPlatformBrowser(platformId);
|
|
29
|
+
}
|
|
30
|
+
SidebarContainer.prototype.ngAfterContentInit = function () {
|
|
31
|
+
if (!this._isBrowser) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
this._onToggle();
|
|
35
|
+
};
|
|
36
|
+
SidebarContainer.prototype.ngOnChanges = function (changes) {
|
|
37
|
+
if (!this._isBrowser) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (changes['showBackdrop']) {
|
|
41
|
+
this.showBackdropChange.emit(changes['showBackdrop'].currentValue);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
SidebarContainer.prototype.ngOnDestroy = function () {
|
|
45
|
+
if (!this._isBrowser) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this._unsubscribe();
|
|
49
|
+
};
|
|
50
|
+
SidebarContainer.prototype._addSidebar = function (sidebar) {
|
|
51
|
+
this._sidebars.push(sidebar);
|
|
52
|
+
this._subscribe(sidebar);
|
|
53
|
+
};
|
|
54
|
+
SidebarContainer.prototype._removeSidebar = function (sidebar) {
|
|
55
|
+
var index = this._sidebars.indexOf(sidebar);
|
|
56
|
+
if (index !== -1) {
|
|
57
|
+
this._sidebars.splice(index, 1);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
SidebarContainer.prototype._getContentStyle = function () {
|
|
61
|
+
var left = 0, right = 0, top = 0, bottom = 0;
|
|
62
|
+
var transformStyle = '';
|
|
63
|
+
var heightStyle = '';
|
|
64
|
+
var widthStyle = '';
|
|
65
|
+
for (var _i = 0, _a = this._sidebars; _i < _a.length; _i++) {
|
|
66
|
+
var sidebar = _a[_i];
|
|
67
|
+
if (sidebar._isModeSlide) {
|
|
68
|
+
if (sidebar.opened) {
|
|
69
|
+
var transformDir = sidebar._isLeftOrRight ? 'X' : 'Y';
|
|
70
|
+
var transformAmt = "" + (sidebar._isLeftOrTop ? '' : '-') + (sidebar._isLeftOrRight ? sidebar._width : sidebar._height);
|
|
71
|
+
transformStyle = "translate" + transformDir + "(" + transformAmt + "px)";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if ((sidebar._isModePush && sidebar.opened) || sidebar.dock) {
|
|
75
|
+
var paddingAmt = 0;
|
|
76
|
+
if (sidebar._isModeSlide && sidebar.opened) {
|
|
77
|
+
if (sidebar._isLeftOrRight) {
|
|
78
|
+
widthStyle = '100%';
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
heightStyle = '100%';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
if (sidebar._isDocked || (sidebar._isModeOver && sidebar.dock)) {
|
|
86
|
+
paddingAmt = sidebar._dockedSize;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
paddingAmt = sidebar._isLeftOrRight ? sidebar._width : sidebar._height;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
switch (sidebar.position) {
|
|
93
|
+
case 'left':
|
|
94
|
+
left = Math.max(left, paddingAmt);
|
|
95
|
+
break;
|
|
96
|
+
case 'right':
|
|
97
|
+
right = Math.max(right, paddingAmt);
|
|
98
|
+
break;
|
|
99
|
+
case 'top':
|
|
100
|
+
top = Math.max(top, paddingAmt);
|
|
101
|
+
break;
|
|
102
|
+
case 'bottom':
|
|
103
|
+
bottom = Math.max(bottom, paddingAmt);
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
padding: top + "px " + right + "px " + bottom + "px " + left + "px",
|
|
110
|
+
webkitTransform: transformStyle,
|
|
111
|
+
transform: transformStyle,
|
|
112
|
+
height: heightStyle,
|
|
113
|
+
width: widthStyle
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
SidebarContainer.prototype._onBackdropClicked = function () {
|
|
117
|
+
var backdropClicked = false;
|
|
118
|
+
for (var _i = 0, _a = this._sidebars; _i < _a.length; _i++) {
|
|
119
|
+
var sidebar = _a[_i];
|
|
120
|
+
if (sidebar.opened && sidebar.showBackdrop && sidebar.closeOnClickBackdrop) {
|
|
121
|
+
sidebar.close();
|
|
122
|
+
backdropClicked = true;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (backdropClicked) {
|
|
126
|
+
this.onBackdropClicked.emit();
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
SidebarContainer.prototype._subscribe = function (sidebar) {
|
|
130
|
+
var _this = this;
|
|
131
|
+
sidebar.onOpenStart.subscribe(function () { return _this._onToggle(); });
|
|
132
|
+
sidebar.onOpened.subscribe(function () { return _this._markForCheck(); });
|
|
133
|
+
sidebar.onCloseStart.subscribe(function () { return _this._onToggle(); });
|
|
134
|
+
sidebar.onClosed.subscribe(function () { return _this._markForCheck(); });
|
|
135
|
+
sidebar.onModeChange.subscribe(function () { return _this._markForCheck(); });
|
|
136
|
+
sidebar.onPositionChange.subscribe(function () { return _this._markForCheck(); });
|
|
137
|
+
sidebar._onRerender.subscribe(function () { return _this._markForCheck(); });
|
|
138
|
+
};
|
|
139
|
+
SidebarContainer.prototype._unsubscribe = function () {
|
|
140
|
+
for (var _i = 0, _a = this._sidebars; _i < _a.length; _i++) {
|
|
141
|
+
var sidebar = _a[_i];
|
|
142
|
+
sidebar.onOpenStart.unsubscribe();
|
|
143
|
+
sidebar.onOpened.unsubscribe();
|
|
144
|
+
sidebar.onCloseStart.unsubscribe();
|
|
145
|
+
sidebar.onClosed.unsubscribe();
|
|
146
|
+
sidebar.onModeChange.unsubscribe();
|
|
147
|
+
sidebar.onPositionChange.unsubscribe();
|
|
148
|
+
sidebar._onRerender.unsubscribe();
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
SidebarContainer.prototype._onToggle = function () {
|
|
152
|
+
var _this = this;
|
|
153
|
+
if (this._sidebars.length > 0 && this.allowSidebarBackdropControl) {
|
|
154
|
+
var hasOpen = this._sidebars.some(function (sidebar) { return sidebar.opened && sidebar.showBackdrop; });
|
|
155
|
+
this.showBackdrop = hasOpen;
|
|
156
|
+
this.showBackdropChange.emit(hasOpen);
|
|
157
|
+
}
|
|
158
|
+
setTimeout(function () {
|
|
159
|
+
_this._markForCheck();
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
SidebarContainer.prototype._markForCheck = function () {
|
|
163
|
+
this._ref.markForCheck();
|
|
164
|
+
};
|
|
165
|
+
SidebarContainer.ɵfac = function SidebarContainer_Factory(t) { return new (t || SidebarContainer)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef), i0.ɵɵdirectiveInject(core_1.PLATFORM_ID)); };
|
|
166
|
+
SidebarContainer.ɵcmp = i0.ɵɵdefineComponent({ type: SidebarContainer, selectors: [["ng-sidebar-container"]], inputs: { animate: "animate", allowSidebarBackdropControl: "allowSidebarBackdropControl", showBackdrop: "showBackdrop", contentClass: "contentClass", backdropClass: "backdropClass" }, outputs: { showBackdropChange: "showBackdropChange", onBackdropClicked: "onBackdropClicked" }, features: [i0.ɵɵNgOnChangesFeature], ngContentSelectors: _c1, decls: 4, vars: 5, consts: [["aria-hidden", "true", "class", "ng-sidebar__backdrop", 3, "ngClass", "click", 4, "ngIf"], [1, "ng-sidebar__content", 3, "ngClass", "ngStyle"], ["aria-hidden", "true", 1, "ng-sidebar__backdrop", 3, "ngClass", "click"]], template: function SidebarContainer_Template(rf, ctx) { if (rf & 1) {
|
|
167
|
+
i0.ɵɵprojectionDef(_c0);
|
|
168
|
+
i0.ɵɵtemplate(0, SidebarContainer_div_0_Template, 1, 1, "div", 0);
|
|
169
|
+
i0.ɵɵprojection(1);
|
|
170
|
+
i0.ɵɵelementStart(2, "div", 1);
|
|
171
|
+
i0.ɵɵprojection(3, 1);
|
|
172
|
+
i0.ɵɵelementEnd();
|
|
173
|
+
} if (rf & 2) {
|
|
174
|
+
i0.ɵɵproperty("ngIf", ctx.showBackdrop);
|
|
175
|
+
i0.ɵɵadvance(2);
|
|
176
|
+
i0.ɵɵclassProp("ng-sidebar__content--animate", ctx.animate);
|
|
177
|
+
i0.ɵɵproperty("ngClass", ctx.contentClass)("ngStyle", ctx._getContentStyle());
|
|
178
|
+
} }, directives: [i1.NgIf, i1.NgClass, i1.NgStyle], styles: ["[_nghost-%COMP%] {\n box-sizing: border-box;\n display: block;\n position: relative;\n height: 100%;\n width: 100%;\n overflow: hidden;\n }\n\n .ng-sidebar__backdrop[_ngcontent-%COMP%] {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n background: #000;\n opacity: 0.75;\n pointer-events: auto;\n z-index: 1;\n }\n\n .ng-sidebar__content[_ngcontent-%COMP%] {\n -webkit-overflow-scrolling: touch;\n overflow: auto;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n }\n\n .ng-sidebar__content--animate[_ngcontent-%COMP%] {\n -webkit-transition: -webkit-transform 0.3s cubic-bezier(0, 0, 0.3, 1), padding 0.3s cubic-bezier(0, 0, 0.3, 1);\n transition: transform 0.3s cubic-bezier(0, 0, 0.3, 1), padding 0.3s cubic-bezier(0, 0, 0.3, 1);\n }"], changeDetection: 0 });
|
|
179
|
+
return SidebarContainer;
|
|
180
|
+
}());
|
|
181
|
+
exports.SidebarContainer = SidebarContainer;
|
|
182
|
+
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SidebarContainer, [{
|
|
183
|
+
type: core_1.Component,
|
|
184
|
+
args: [{
|
|
185
|
+
selector: 'ng-sidebar-container',
|
|
186
|
+
template: "\n <div *ngIf=\"showBackdrop\"\n aria-hidden=\"true\"\n class=\"ng-sidebar__backdrop\"\n [ngClass]=\"backdropClass\"\n (click)=\"_onBackdropClicked()\"></div>\n\n <ng-content select=\"ng-sidebar,[ng-sidebar]\"></ng-content>\n\n <div class=\"ng-sidebar__content\"\n [class.ng-sidebar__content--animate]=\"animate\"\n [ngClass]=\"contentClass\"\n [ngStyle]=\"_getContentStyle()\">\n <ng-content select=\"[ng-sidebar-content]\"></ng-content>\n </div>\n ",
|
|
187
|
+
styles: ["\n :host {\n box-sizing: border-box;\n display: block;\n position: relative;\n height: 100%;\n width: 100%;\n overflow: hidden;\n }\n\n .ng-sidebar__backdrop {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n background: #000;\n opacity: 0.75;\n pointer-events: auto;\n z-index: 1;\n }\n\n .ng-sidebar__content {\n -webkit-overflow-scrolling: touch;\n overflow: auto;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n }\n\n .ng-sidebar__content--animate {\n -webkit-transition: -webkit-transform 0.3s cubic-bezier(0, 0, 0.3, 1), padding 0.3s cubic-bezier(0, 0, 0.3, 1);\n transition: transform 0.3s cubic-bezier(0, 0, 0.3, 1), padding 0.3s cubic-bezier(0, 0, 0.3, 1);\n }\n "],
|
|
188
|
+
changeDetection: core_1.ChangeDetectionStrategy.OnPush
|
|
189
|
+
}]
|
|
190
|
+
}], function () { return [{ type: i0.ChangeDetectorRef }, { type: Object, decorators: [{
|
|
191
|
+
type: core_1.Inject,
|
|
192
|
+
args: [core_1.PLATFORM_ID]
|
|
193
|
+
}] }]; }, { animate: [{
|
|
194
|
+
type: core_1.Input
|
|
195
|
+
}], allowSidebarBackdropControl: [{
|
|
196
|
+
type: core_1.Input
|
|
197
|
+
}], showBackdrop: [{
|
|
198
|
+
type: core_1.Input
|
|
199
|
+
}], showBackdropChange: [{
|
|
200
|
+
type: core_1.Output
|
|
201
|
+
}], onBackdropClicked: [{
|
|
202
|
+
type: core_1.Output
|
|
203
|
+
}], contentClass: [{
|
|
204
|
+
type: core_1.Input
|
|
205
|
+
}], backdropClass: [{
|
|
206
|
+
type: core_1.Input
|
|
207
|
+
}] }); })();
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { AfterContentInit, ChangeDetectorRef, ElementRef, EventEmitter, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core';
|
|
2
|
+
import { SidebarContainer } from './sidebar-container.component';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare class Sidebar implements AfterContentInit, OnInit, OnChanges, OnDestroy {
|
|
5
|
+
private _container;
|
|
6
|
+
private _ref;
|
|
7
|
+
opened: boolean;
|
|
8
|
+
openedChange: EventEmitter<boolean>;
|
|
9
|
+
mode: 'over' | 'push' | 'slide';
|
|
10
|
+
dock: boolean;
|
|
11
|
+
dockedSize: string;
|
|
12
|
+
position: 'start' | 'end' | 'left' | 'right' | 'top' | 'bottom';
|
|
13
|
+
animate: boolean;
|
|
14
|
+
autoCollapseHeight: number;
|
|
15
|
+
autoCollapseWidth: number;
|
|
16
|
+
autoCollapseOnInit: boolean;
|
|
17
|
+
sidebarClass: string;
|
|
18
|
+
ariaLabel: string;
|
|
19
|
+
trapFocus: boolean;
|
|
20
|
+
autoFocus: boolean;
|
|
21
|
+
showBackdrop: boolean;
|
|
22
|
+
closeOnClickBackdrop: boolean;
|
|
23
|
+
closeOnClickOutside: boolean;
|
|
24
|
+
keyClose: boolean;
|
|
25
|
+
keyCode: number;
|
|
26
|
+
onContentInit: EventEmitter<null>;
|
|
27
|
+
onOpenStart: EventEmitter<null>;
|
|
28
|
+
onOpened: EventEmitter<null>;
|
|
29
|
+
onCloseStart: EventEmitter<null>;
|
|
30
|
+
onClosed: EventEmitter<null>;
|
|
31
|
+
onTransitionEnd: EventEmitter<null>;
|
|
32
|
+
onModeChange: EventEmitter<string>;
|
|
33
|
+
onPositionChange: EventEmitter<string>;
|
|
34
|
+
_onRerender: EventEmitter<null>;
|
|
35
|
+
_elSidebar: ElementRef;
|
|
36
|
+
private _focusableElementsString;
|
|
37
|
+
private _focusableElements;
|
|
38
|
+
private _focusedBeforeOpen;
|
|
39
|
+
private _tabIndexAttr;
|
|
40
|
+
private _tabIndexIndicatorAttr;
|
|
41
|
+
private _wasCollapsed;
|
|
42
|
+
private _shouldAnimate;
|
|
43
|
+
private _clickEvent;
|
|
44
|
+
private _onClickOutsideAttached;
|
|
45
|
+
private _onKeyDownAttached;
|
|
46
|
+
private _onResizeAttached;
|
|
47
|
+
private _isBrowser;
|
|
48
|
+
constructor(_container: SidebarContainer, _ref: ChangeDetectorRef, platformId: Object);
|
|
49
|
+
ngOnInit(): void;
|
|
50
|
+
ngAfterContentInit(): void;
|
|
51
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
52
|
+
ngOnDestroy(): void;
|
|
53
|
+
open(): void;
|
|
54
|
+
close(): void;
|
|
55
|
+
triggerRerender(): void;
|
|
56
|
+
_getStyle(): CSSStyleDeclaration;
|
|
57
|
+
_onTransitionEnd(e: TransitionEvent): void;
|
|
58
|
+
private get _shouldTrapFocus();
|
|
59
|
+
private _focusFirstItem;
|
|
60
|
+
private _onFocusTrap;
|
|
61
|
+
private _setFocused;
|
|
62
|
+
private _initCloseListeners;
|
|
63
|
+
private _initCloseClickListener;
|
|
64
|
+
private _initCloseKeyDownListener;
|
|
65
|
+
private _destroyCloseListeners;
|
|
66
|
+
private _destroyCloseClickListener;
|
|
67
|
+
private _destroyCloseKeyDownListener;
|
|
68
|
+
private _onClickOutside;
|
|
69
|
+
private _onKeyDown;
|
|
70
|
+
private _initCollapseListeners;
|
|
71
|
+
private _destroyCollapseListeners;
|
|
72
|
+
private _collapse;
|
|
73
|
+
get _height(): number;
|
|
74
|
+
get _width(): number;
|
|
75
|
+
get _dockedSize(): number;
|
|
76
|
+
get _isModeOver(): boolean;
|
|
77
|
+
get _isModePush(): boolean;
|
|
78
|
+
get _isModeSlide(): boolean;
|
|
79
|
+
get _isDocked(): boolean;
|
|
80
|
+
get _isLeftOrTop(): boolean;
|
|
81
|
+
get _isLeftOrRight(): boolean;
|
|
82
|
+
get _isInert(): boolean;
|
|
83
|
+
private _normalizePosition;
|
|
84
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<Sidebar, [{ optional: true; }, null, null]>;
|
|
85
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<Sidebar, "ng-sidebar", never, { "opened": "opened"; "mode": "mode"; "dock": "dock"; "dockedSize": "dockedSize"; "position": "position"; "animate": "animate"; "autoCollapseHeight": "autoCollapseHeight"; "autoCollapseWidth": "autoCollapseWidth"; "autoCollapseOnInit": "autoCollapseOnInit"; "sidebarClass": "sidebarClass"; "ariaLabel": "ariaLabel"; "trapFocus": "trapFocus"; "autoFocus": "autoFocus"; "showBackdrop": "showBackdrop"; "closeOnClickBackdrop": "closeOnClickBackdrop"; "closeOnClickOutside": "closeOnClickOutside"; "keyClose": "keyClose"; "keyCode": "keyCode"; }, { "openedChange": "openedChange"; "onContentInit": "onContentInit"; "onOpenStart": "onOpenStart"; "onOpened": "onOpened"; "onCloseStart": "onCloseStart"; "onClosed": "onClosed"; "onTransitionEnd": "onTransitionEnd"; "onModeChange": "onModeChange"; "onPositionChange": "onPositionChange"; "_onRerender": "_onRerender"; }, never, ["*"]>;
|
|
86
|
+
}
|