@frontile/overlays 0.15.0 → 0.16.0-alpha.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.
Files changed (99) hide show
  1. package/addon-main.js +4 -0
  2. package/declarations/components/drawer/body.d.ts +15 -0
  3. package/declarations/components/drawer/body.d.ts.map +1 -0
  4. package/declarations/components/drawer/footer.d.ts +15 -0
  5. package/declarations/components/drawer/footer.d.ts.map +1 -0
  6. package/{components → declarations/components}/drawer/header.d.ts +7 -2
  7. package/declarations/components/drawer/header.d.ts.map +1 -0
  8. package/{components → declarations/components}/drawer/index.d.ts +10 -8
  9. package/declarations/components/drawer/index.d.ts.map +1 -0
  10. package/{components → declarations/components}/modal/body.d.ts +5 -1
  11. package/declarations/components/modal/body.d.ts.map +1 -0
  12. package/{components → declarations/components}/modal/footer.d.ts +5 -1
  13. package/declarations/components/modal/footer.d.ts.map +1 -0
  14. package/{components → declarations/components}/modal/header.d.ts +5 -1
  15. package/declarations/components/modal/header.d.ts.map +1 -0
  16. package/{components → declarations/components}/modal/index.d.ts +10 -8
  17. package/declarations/components/modal/index.d.ts.map +1 -0
  18. package/{components → declarations/components}/overlay.d.ts +5 -1
  19. package/declarations/components/overlay.d.ts.map +1 -0
  20. package/declarations/template-registry.d.ts +9 -0
  21. package/declarations/template-registry.d.ts.map +1 -0
  22. package/dist/_app_/components/drawer/body.js +1 -0
  23. package/dist/_app_/components/drawer/footer.js +1 -0
  24. package/dist/_app_/components/drawer/header.js +1 -0
  25. package/dist/_app_/components/drawer/index.js +1 -0
  26. package/dist/_app_/components/modal/body.js +1 -0
  27. package/dist/_app_/components/modal/footer.js +1 -0
  28. package/dist/_app_/components/modal/header.js +1 -0
  29. package/dist/_app_/components/modal/index.js +1 -0
  30. package/dist/_app_/components/overlay.js +1 -0
  31. package/dist/components/drawer/body.js +17 -0
  32. package/dist/components/drawer/body.js.map +1 -0
  33. package/dist/components/drawer/footer.js +17 -0
  34. package/dist/components/drawer/footer.js.map +1 -0
  35. package/dist/components/drawer/header.js +17 -0
  36. package/dist/components/drawer/header.js.map +1 -0
  37. package/dist/components/drawer/index.js +50 -0
  38. package/dist/components/drawer/index.js.map +1 -0
  39. package/dist/components/modal/body.js +17 -0
  40. package/dist/components/modal/body.js.map +1 -0
  41. package/dist/components/modal/footer.js +17 -0
  42. package/dist/components/modal/footer.js.map +1 -0
  43. package/dist/components/modal/header.js +17 -0
  44. package/dist/components/modal/header.js.map +1 -0
  45. package/dist/components/modal/index.js +45 -0
  46. package/dist/components/modal/index.js.map +1 -0
  47. package/dist/components/overlay.js +182 -0
  48. package/dist/components/overlay.js.map +1 -0
  49. package/dist/template-registry.js +2 -0
  50. package/dist/template-registry.js.map +1 -0
  51. package/package.json +84 -51
  52. package/-private/dom.d.ts +0 -5
  53. package/addon/-private/dom.d.ts +0 -5
  54. package/addon/-private/dom.js +0 -61
  55. package/addon/components/drawer/body.hbs +0 -6
  56. package/addon/components/drawer/body.ts +0 -12
  57. package/addon/components/drawer/demo/composition.md +0 -94
  58. package/addon/components/drawer/demo/placements.md +0 -60
  59. package/addon/components/drawer/demo/sizes.md +0 -60
  60. package/addon/components/drawer/demo/usage.md +0 -73
  61. package/addon/components/drawer/footer.hbs +0 -6
  62. package/addon/components/drawer/footer.ts +0 -12
  63. package/addon/components/drawer/header.hbs +0 -7
  64. package/addon/components/drawer/header.ts +0 -16
  65. package/addon/components/drawer/index.hbs +0 -43
  66. package/addon/components/drawer/index.md +0 -9
  67. package/addon/components/drawer/index.ts +0 -94
  68. package/addon/components/modal/body.hbs +0 -6
  69. package/addon/components/modal/body.ts +0 -11
  70. package/addon/components/modal/demo/sizes.md +0 -61
  71. package/addon/components/modal/demo/usage.md +0 -73
  72. package/addon/components/modal/footer.hbs +0 -6
  73. package/addon/components/modal/footer.ts +0 -11
  74. package/addon/components/modal/header.hbs +0 -7
  75. package/addon/components/modal/header.ts +0 -16
  76. package/addon/components/modal/index.hbs +0 -43
  77. package/addon/components/modal/index.md +0 -9
  78. package/addon/components/modal/index.ts +0 -84
  79. package/addon/components/overlay-demo/usage.md +0 -42
  80. package/addon/components/overlay.hbs +0 -68
  81. package/addon/components/overlay.md +0 -24
  82. package/addon/components/overlay.ts +0 -217
  83. package/app/components/drawer/body.js +0 -1
  84. package/app/components/drawer/footer.js +0 -1
  85. package/app/components/drawer/header.js +0 -1
  86. package/app/components/drawer.js +0 -1
  87. package/app/components/modal/body.js +0 -1
  88. package/app/components/modal/footer.js +0 -1
  89. package/app/components/modal/header.js +0 -1
  90. package/app/components/modal.js +0 -1
  91. package/app/components/overlay.js +0 -1
  92. package/components/drawer/body.d.ts +0 -10
  93. package/components/drawer/footer.d.ts +0 -10
  94. package/config/environment.js +0 -5
  95. package/index.js +0 -5
  96. package/tsconfig.json +0 -23
  97. package/types/dummy/index.d.ts +0 -0
  98. package/types/global.d.ts +0 -6
  99. package/types/index.d.ts +0 -1
@@ -1,42 +0,0 @@
1
- ---
2
- order: 1
3
- ---
4
-
5
- # Usage
6
-
7
- ```hbs template
8
- <Button
9
- {{on "click" this.toggle}}
10
- >
11
- Open Overlay
12
- </Button>
13
-
14
- <Overlay
15
- @isOpen={{this.isOpen}}
16
- @onClose={{this.toggle}}
17
- as |m|
18
- >
19
- <div class="bg-white p-8">
20
- <p>Some contents...</p>
21
- <p>Some contents...</p>
22
- <p>Some contents...</p>
23
- <Button {{on "click" this.toggle}}>Close</Button>
24
- </div>
25
- </Overlay>
26
- ```
27
-
28
- ```js component
29
- import Component from '@glimmer/component';
30
- import { tracked } from '@glimmer/tracking';
31
- import { action } from '@ember/object';
32
- import { later } from '@ember/runloop';
33
-
34
- export default class DemoModal extends Component {
35
- @tracked isOpen = false;
36
- @tracked isLoading = false;
37
-
38
- @action toggle() {
39
- this.isOpen = !this.isOpen;
40
- }
41
- }
42
- ```
@@ -1,68 +0,0 @@
1
- {{#if this.isVisible}}
2
- {{#maybe-in-element this.destinationElement @renderInPlace insertBefore=null}}
3
- <div
4
- class={{use-frontile-class "overlay" (if @renderInPlace "in-place")}}
5
- ...attributes
6
- {{focus-trap
7
- isActive=(if @disableFocusTrap false @isOpen)
8
- focusTrapOptions=this.focusTrapOptions
9
- }}
10
- >
11
- {{! template-lint-disable no-invalid-interactive }}
12
- {{#if this.isBackdropVisible}}
13
- <div
14
- class={{
15
- use-frontile-class
16
- "overlay"
17
- (if @renderInPlace "in-place")
18
- part="backdrop"
19
- }}
20
- {{on "click" this.handleOverlayClick}}
21
- {{css-transition
22
- (if
23
- @backdropTransitionName
24
- @backdropTransitionName
25
- "overlay-transition--fade"
26
- )
27
- isEnabled=this.isAnimationEnabled
28
- }}
29
- ></div>
30
- {{/if}}
31
-
32
- {{!
33
- This is required to make css-transition work with 2
34
- sibling elements been removed at the same time.
35
- }}
36
- <span data-is-visible={{this.isVisible}}></span>
37
-
38
- {{#if @isOpen}}
39
- {{! template-lint-disable no-pointer-down-event-binding }}
40
- <div
41
- class={{
42
- use-frontile-class
43
- "overlay"
44
- (if @renderInPlace "in-place")
45
- part="content"
46
- }}
47
- {{on "click" this.handleContentClick}}
48
- {{on "keydown" this.handleKeyDown}}
49
- {{on "mousedown" this.handleContentMouseDown}}
50
- {{did-insert this.setup}}
51
- {{will-destroy this.teardown}}
52
- {{css-transition
53
- (if
54
- @contentTransitionName
55
- @contentTransitionName
56
- "overlay-transition--fade"
57
- )
58
- isEnabled=this.isAnimationEnabled
59
- }}
60
- >
61
- {{! template-lint-enable no-pointer-down-event-binding }}
62
- {{yield}}
63
- </div>
64
- {{/if}}
65
- {{! template-lint-enable no-invalid-interactive }}
66
- </div>
67
- {{/maybe-in-element}}
68
- {{/if}}
@@ -1,24 +0,0 @@
1
- # Overlay
2
-
3
- The Overlay component is the base for building interactions like Modal and Drawer.
4
- It contains all the core features necessary for a great experience.
5
-
6
- - Auto-Focusing
7
- - Focus Trapping
8
- - Render in-Place or in-Portal.
9
- - Press `Esc` to dismiss
10
- - Click on the backdrop to dismiss
11
- - Animations
12
-
13
- > Important: You must have a focusable element inside of the Overlay.
14
-
15
- ## Note on Overlays and other portal elements
16
-
17
- `FormSelect` uses Power Select under the hood and has `@renderInPlace={{false}}` set by default, which will insert the content of the drop-down outside of the `Overlay` (or `Drawer` or `Modal`) and because of that focus-trap will prevent accessing focusable elements ([search input](https://ember-power-select.com/docs/the-search)) in said Power Select. To solve this you have following options:
18
-
19
- - `<Overlay @disableFocusTrap={{true}} />` (not recommended)
20
- - `<FormSelect @renderInPlace={{true}} />` (recommended)
21
-
22
- ## API
23
-
24
- <ArgsTable @of="Overlay" />
@@ -1,217 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { tracked } from '@glimmer/tracking';
3
- import { action } from '@ember/object';
4
- import { later } from '@ember/runloop';
5
- import { getDOM, getElementById } from '../-private/dom';
6
-
7
- export interface OverlayArgs {
8
- /**
9
- * Whether to render in place or in the specified/default destination
10
- *
11
- * @defaultValue false
12
- */
13
- renderInPlace?: boolean;
14
-
15
- /**
16
- * The destination where the overlay will be inserted, defaults to
17
- * `document.body`
18
- *
19
- * @defaultValue undefined
20
- */
21
- destinationElementId?: string;
22
-
23
- /**
24
- * Duration of the animation
25
- *
26
- * @defaultValue 200
27
- */
28
- transitionDuration?: number;
29
-
30
- /**
31
- * Whether to hide the backdrop or not
32
- *
33
- * @defaultValue false
34
- */
35
- disableBackdrop?: boolean;
36
-
37
- /**
38
- * Disable css transitions
39
- *
40
- * @defaultValue false
41
- */
42
- disableTransitions?: boolean;
43
-
44
- /**
45
- * Whether the focus trap is disabled or not
46
- *
47
- * @defaultValue false
48
- */
49
- disableFocusTrap?: boolean;
50
-
51
- /**
52
- * Focus trap options
53
- *
54
- * @defaultValue { allowOutsideClick: true }
55
- */
56
- focusTrapOptions?: unknown;
57
-
58
- /**
59
- * Whether it is open or not
60
- */
61
- isOpen: boolean;
62
-
63
- /**
64
- * A function that will be called when closed
65
- */
66
- onClose?: () => void;
67
-
68
- /**
69
- * A function that will be called when closing is finished executing, this
70
- * includes waiting for animations/transitions to finish.
71
- */
72
- didClose?: () => void;
73
-
74
- /**
75
- * A function that will be called when opened
76
- */
77
- onOpen?: () => void;
78
-
79
- /**
80
- * Whether to close when the area outside (the backdrop) is clicked
81
- *
82
- * @defaultValue true
83
- */
84
- closeOnOutsideClick?: boolean;
85
-
86
- /**
87
- * Whether to close when the escape key is pressed
88
- *
89
- * @defaultValue true
90
- */
91
- closeOnEscapeKey?: boolean;
92
-
93
- /**
94
- * The name of the transition to be used in the backdrop.
95
- *
96
- * @defaultValue 'overlay-transition--fade'
97
- */
98
- backdropTransitionName?: string;
99
-
100
- /**
101
- * The name of the transition to be used in the content.
102
- *
103
- * @defaultValue 'overlay-transition--fade'
104
- */
105
- contentTransitionName?: string;
106
- }
107
-
108
- export interface OverlaySignature {
109
- Args: OverlayArgs;
110
- Element: HTMLDivElement | null;
111
- }
112
-
113
- export default class Overlay extends Component<OverlaySignature> {
114
- @tracked keepOpen = false;
115
- contentElement: HTMLElement | undefined;
116
- mouseDownContentElement: EventTarget | null = null;
117
-
118
- get destinationElement(): HTMLElement | null {
119
- const doc = getDOM(this);
120
-
121
- if (!doc) {
122
- return null;
123
- }
124
-
125
- if (this.args.destinationElementId) {
126
- return getElementById(doc, this.args.destinationElementId);
127
- } else {
128
- return doc.body;
129
- }
130
- }
131
-
132
- get isVisible(): boolean {
133
- return this.args.isOpen || this.keepOpen;
134
- }
135
-
136
- get isBackdropVisible(): boolean {
137
- return Boolean(this.args.isOpen && this.args.disableBackdrop !== true);
138
- }
139
-
140
- get isAnimationEnabled(): boolean {
141
- return !(this.args.disableTransitions === true);
142
- }
143
-
144
- get focusTrapOptions(): unknown {
145
- return this.args.focusTrapOptions || { allowOutsideClick: true };
146
- }
147
-
148
- @action handleOverlayClick(): void {
149
- if (this.args.closeOnOutsideClick !== false) {
150
- this.handleClose();
151
- }
152
- }
153
-
154
- @action handleContentClick(event: MouseEvent): void {
155
- if (
156
- this.args.closeOnOutsideClick !== false &&
157
- event.target === this.contentElement &&
158
- this.mouseDownContentElement == this.contentElement
159
- ) {
160
- this.handleClose();
161
- }
162
- this.mouseDownContentElement = null;
163
- }
164
-
165
- @action handleClose(): void {
166
- if (typeof this.args.onClose === 'function') {
167
- this.args.onClose();
168
- }
169
- }
170
-
171
- @action
172
- handleContentMouseDown(event: MouseEvent): void {
173
- this.mouseDownContentElement = event.target;
174
- }
175
-
176
- @action
177
- handleKeyDown(event: KeyboardEvent): void {
178
- if (event.key === 'Escape' && this.args.closeOnEscapeKey !== false) {
179
- this.handleClose();
180
- }
181
- }
182
-
183
- @action setup(element: HTMLElement): void {
184
- this.contentElement = element;
185
- this.keepOpen = true;
186
-
187
- if (this.args.renderInPlace !== true) {
188
- document.body.style.overflow = 'hidden';
189
- }
190
-
191
- if (typeof this.args.onOpen === 'function') {
192
- this.args.onOpen();
193
- }
194
- }
195
-
196
- @action teardown(): void {
197
- this.contentElement = undefined;
198
-
199
- if (this.args.renderInPlace !== true && document.body.classList) {
200
- document.body.style.overflow = '';
201
- }
202
-
203
- let duration = this.args.transitionDuration || 200;
204
-
205
- if (this.args.disableTransitions === true) {
206
- duration = 0;
207
- }
208
-
209
- const { didClose } = this.args;
210
- later(() => {
211
- if (!this.isDestroyed) this.keepOpen = false;
212
- if (typeof didClose === 'function' && !this.isDestroyed) {
213
- didClose();
214
- }
215
- }, duration);
216
- }
217
- }
@@ -1 +0,0 @@
1
- export { default } from '@frontile/overlays/components/drawer/body';
@@ -1 +0,0 @@
1
- export { default } from '@frontile/overlays/components/drawer/footer';
@@ -1 +0,0 @@
1
- export { default } from '@frontile/overlays/components/drawer/header';
@@ -1 +0,0 @@
1
- export { default } from '@frontile/overlays/components/drawer';
@@ -1 +0,0 @@
1
- export { default } from '@frontile/overlays/components/modal/body';
@@ -1 +0,0 @@
1
- export { default } from '@frontile/overlays/components/modal/footer';
@@ -1 +0,0 @@
1
- export { default } from '@frontile/overlays/components/modal/header';
@@ -1 +0,0 @@
1
- export { default } from '@frontile/overlays/components/modal';
@@ -1 +0,0 @@
1
- export { default } from '@frontile/overlays/components/overlay';
@@ -1,10 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { DrawerArgs } from '.';
3
- export interface DrawerBodyArgs extends Pick<DrawerArgs, 'size' | 'placement'> {
4
- }
5
- export interface DrawerBodySignature {
6
- Args: DrawerBodyArgs;
7
- Element: HTMLDivElement | null;
8
- }
9
- export default class DrawerBody extends Component<DrawerBodySignature> {
10
- }
@@ -1,10 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { DrawerArgs } from '.';
3
- export interface DrawerFooterArgs extends Pick<DrawerArgs, 'size' | 'placement'> {
4
- }
5
- export interface DrawerFooterSignature {
6
- Args: DrawerFooterArgs;
7
- Element: HTMLDivElement | null;
8
- }
9
- export default class DrawerFooter extends Component<DrawerFooterSignature> {
10
- }
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = function (/* environment, appConfig */) {
4
- return {};
5
- };
package/index.js DELETED
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- name: require('./package').name
5
- };
package/tsconfig.json DELETED
@@ -1,23 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "baseUrl": ".",
5
- "paths": {
6
- "dummy/tests/*": ["tests/*"],
7
- "dummy/*": ["tests/dummy/app/*", "app/*"],
8
- "@frontile/overlays": ["addon"],
9
- "@frontile/overlays/*": ["addon/*"],
10
- "@frontile/overlays/test-support": ["addon-test-support"],
11
- "@frontile/overlays/test-support/*": ["addon-test-support/*"],
12
- "*": ["types/*"]
13
- }
14
- },
15
- "include": [
16
- "app/**/*",
17
- "addon/**/*",
18
- "tests/**/*",
19
- "types/**/*",
20
- "test-support/**/*",
21
- "addon-test-support/**/*"
22
- ]
23
- }
File without changes
package/types/global.d.ts DELETED
@@ -1,6 +0,0 @@
1
- // Types for compiled templates
2
- declare module '@frontile/overlays/templates/*' {
3
- import { TemplateFactory } from 'htmlbars-inline-precompile';
4
- const tmpl: TemplateFactory;
5
- export default tmpl;
6
- }
package/types/index.d.ts DELETED
@@ -1 +0,0 @@
1
- import 'ember-source/types';