@plusui/library 0.1.14 → 0.1.16
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/cdn/components/accordion/accordion.js +1 -1
- package/cdn/components/accordion/index.js +1 -1
- package/cdn/components/accordion-group/accordion-group.js +1 -1
- package/cdn/components/accordion-group/index.js +1 -1
- package/cdn/components/alert/alert.js +1 -1
- package/cdn/components/alert/index.js +1 -1
- package/cdn/components/avatar/avatar.js +1 -1
- package/cdn/components/avatar/index.js +1 -1
- package/cdn/components/badge/badge.js +1 -1
- package/cdn/components/badge/index.js +1 -1
- package/cdn/components/base/index.js +1 -1
- package/cdn/components/base/tailwind-base.js +1 -1
- package/cdn/components/breadcrumb/breadcrumb.js +1 -1
- package/cdn/components/breadcrumb/index.js +1 -1
- package/cdn/components/breadcrumb-item/breadcrumb-item.js +1 -1
- package/cdn/components/breadcrumb-item/index.js +1 -1
- package/cdn/components/button/button.js +1 -1
- package/cdn/components/button/index.js +1 -1
- package/cdn/components/button-group/button-group.js +1 -1
- package/cdn/components/button-group/index.js +1 -1
- package/cdn/components/checkbox/checkbox.js +1 -1
- package/cdn/components/checkbox/index.js +1 -1
- package/cdn/components/checkbox-group/checkbox-group.js +1 -1
- package/cdn/components/checkbox-group/index.js +1 -1
- package/cdn/components/chip/chip.js +1 -1
- package/cdn/components/chip/index.js +1 -1
- package/cdn/components/divider/divider.js +1 -1
- package/cdn/components/divider/index.js +1 -1
- package/cdn/components/drawer/drawer.js +1 -1
- package/cdn/components/drawer/index.js +1 -1
- package/cdn/components/dropdown/dropdown.js +1 -1
- package/cdn/components/dropdown/index.js +1 -1
- package/cdn/components/dropdown-item/dropdown-item.js +1 -1
- package/cdn/components/dropdown-item/index.js +1 -1
- package/cdn/components/index.js +1 -1
- package/cdn/components/input/index.js +1 -1
- package/cdn/components/input/input.js +1 -1
- package/cdn/components/link/index.js +1 -1
- package/cdn/components/link/link.js +1 -1
- package/cdn/components/list-box-item/index.js +1 -1
- package/cdn/components/list-box-item/list-box-item.js +1 -1
- package/cdn/components/modal/index.js +5 -1
- package/cdn/components/modal/modal.js +340 -83
- package/cdn/components/modal/modal.style.js +70 -41
- package/cdn/components/popconfirm/index.js +1 -1
- package/cdn/components/popconfirm/popconfirm.js +1 -1
- package/cdn/components/popover/index.js +1 -1
- package/cdn/components/popover/popover.js +1 -1
- package/cdn/components/radio/index.js +1 -1
- package/cdn/components/radio/radio.js +1 -1
- package/cdn/components/radio-group/index.js +1 -1
- package/cdn/components/radio-group/radio-group.js +1 -1
- package/cdn/components/rating/index.js +1 -1
- package/cdn/components/rating/rating.js +1 -1
- package/cdn/components/segmented-picker/index.js +1 -1
- package/cdn/components/segmented-picker/segmented-picker.component.js +1 -1
- package/cdn/components/segmented-picker-item/index.js +1 -1
- package/cdn/components/segmented-picker-item/segmented-picker-item.component.js +1 -1
- package/cdn/components/select/index.js +1 -1
- package/cdn/components/select/select.js +1 -1
- package/cdn/components/select-item/index.js +1 -1
- package/cdn/components/select-item/select-item.js +1 -1
- package/cdn/components/service/index.js +1 -1
- package/cdn/components/service/service.js +1 -1
- package/cdn/components/tab/index.js +1 -1
- package/cdn/components/tab/tab.js +1 -1
- package/cdn/components/tab-group/index.js +1 -1
- package/cdn/components/tab-group/tab-group.js +1 -1
- package/cdn/components/tab-panel/index.js +1 -1
- package/cdn/components/tab-panel/tab-panel.js +1 -1
- package/cdn/components/tag/index.js +1 -1
- package/cdn/components/tag/tag.js +1 -1
- package/cdn/components/text/index.js +1 -1
- package/cdn/components/text/text.js +1 -1
- package/cdn/components/textarea/index.js +1 -1
- package/cdn/components/textarea/textarea.js +1 -1
- package/cdn/components/toast/index.js +1 -1
- package/cdn/components/toast/toast.js +1 -1
- package/cdn/components/toast-container/index.js +1 -1
- package/cdn/components/toast-container/toast-container.js +1 -1
- package/cdn/components/toggle/index.js +1 -1
- package/cdn/components/toggle/toggle.js +1 -1
- package/cdn/components/tooltip/index.js +1 -1
- package/cdn/components/tooltip/tooltip.js +1 -1
- package/cdn/factory/tailwind-factory.js +1 -1
- package/cdn/global-BfmuDcaf.js +1 -0
- package/cdn/global-m-W73pez.js +31 -0
- package/custom-elements.json +226 -25
- package/dist/components/modal/index.js +4 -0
- package/dist/components/modal/modal.d.ts +95 -22
- package/dist/components/modal/modal.d.ts.map +1 -1
- package/dist/components/modal/modal.js +339 -82
- package/dist/components/modal/modal.js.map +1 -1
- package/dist/components/modal/modal.style.d.ts +297 -122
- package/dist/components/modal/modal.style.d.ts.map +1 -1
- package/dist/components/modal/modal.style.js +70 -41
- package/dist/components/modal/modal.style.js.map +1 -1
- package/dist/{if-defined-CAh2WTyo.js → if-defined-DzyJw9oN.js} +1 -1
- package/dist/index.css +2 -2
- package/dist/{live-CSPSCWrs.js → live-Dlj-D15j.js} +1 -1
- package/dist/{property-BXP8koCN.js → property-DRwbRRVL.js} +1 -1
- package/dist/{query-DixClzz3.js → query-CVSIfDVf.js} +1 -1
- package/dist/{query-assigned-elements-tu2Z4Umd.js → query-assigned-elements-CGjtMDM7.js} +1 -1
- package/dist/{state-CRctcY5E.js → state-DibUHyPK.js} +1 -1
- package/dist/{style-map-BP6cVC6K.js → style-map-DE-r4ozp.js} +1 -1
- package/dist/styles/global.js +2 -2
- package/eslint/custom-element-eslint-rules.js +16 -0
- package/package.json +1 -1
- package/public/html/index.js +406 -124
- package/public/react/index.d.ts +145 -33
- package/public/react/index.js +430 -125
- package/react/PlusModal.d.ts +50 -11
- package/react/PlusModal.js +31 -2
- package/types/custom-element-jsx.d.ts +42 -11
- package/types/custom-element-solidjs.d.ts +42 -11
- package/types/custom-element-svelte.d.ts +42 -11
- package/types/custom-element-vuejs.d.ts +42 -11
- package/vscode.css-custom-data.json +10 -6
- package/vscode.html-custom-data.json +26 -1
- package/web-types.json +106 -11
- package/cdn/global-8uGSRUk7.js +0 -31
- package/cdn/global-DklV2dCX.js +0 -1
- /package/dist/{base-CesIX8_4.js → base-CJK80TT1.js} +0 -0
- /package/dist/{directive-BUtBNK63.js → directive-DJonW9K-.js} +0 -0
- /package/dist/{floating-ui.dom-DEPWsfNe.js → floating-ui.dom-Cx1F5m3b.js} +0 -0
- /package/dist/{index-CwglOP_H.js → index-B49PNGQM.js} +0 -0
- /package/dist/{lit-element-u_ybFE-X.js → lit-element-BS9RbLkf.js} +0 -0
|
@@ -1,43 +1,67 @@
|
|
|
1
1
|
import { _ as __decorate, n } from '../../property-DiPQx9S3.js';
|
|
2
2
|
import { x } from '../../lit-element-ByzbtpGk.js';
|
|
3
3
|
import { r } from '../../state-D1d5Sfj8.js';
|
|
4
|
+
import { e } from '../../query-CHb9Ft_d.js';
|
|
5
|
+
import { o } from '../../style-map-DC_vNus2.js';
|
|
4
6
|
import { booleanConverter } from '../../utils/boolean-converter.js';
|
|
5
7
|
import { modalStyle } from './modal.style.js';
|
|
6
8
|
import Tailwind from '../base/tailwind-base.js';
|
|
9
|
+
import '../../base-Cl6v8-BZ.js';
|
|
10
|
+
import '../../directive-DZCF8pFJ.js';
|
|
7
11
|
import '../../index-B9iart53.js';
|
|
8
|
-
import '../../global-
|
|
12
|
+
import '../../global-m-W73pez.js';
|
|
9
13
|
|
|
10
14
|
/**
|
|
11
15
|
* @tag plus-modal
|
|
12
|
-
* @summary Modal dialog component
|
|
16
|
+
* @summary Modal dialog component built on native HTML Dialog API. Displays content in a layer above the page with full keyboard and focus management.
|
|
13
17
|
*
|
|
18
|
+
* @slot - Main content area (same as body slot)
|
|
14
19
|
* @slot header - The header content of the modal
|
|
15
|
-
* @slot body - The main content of the modal
|
|
20
|
+
* @slot body - The main content of the modal (alternative to default slot)
|
|
16
21
|
* @slot footer - The footer content of the modal
|
|
17
22
|
* @slot close - Custom close button (defaults to an X icon)
|
|
18
23
|
*
|
|
19
|
-
* @csspart
|
|
20
|
-
* @csspart
|
|
21
|
-
* @csspart modal - The modal
|
|
22
|
-
* @csspart header - The header
|
|
23
|
-
* @csspart
|
|
24
|
-
* @csspart
|
|
24
|
+
* @csspart dialog - The native dialog element
|
|
25
|
+
* @csspart container - The container wrapper for centering and scrolling
|
|
26
|
+
* @csspart modal - The main modal box
|
|
27
|
+
* @csspart header - The header section
|
|
28
|
+
* @csspart header-content - The content wrapper inside header
|
|
29
|
+
* @csspart body - The main content area
|
|
30
|
+
* @csspart footer - The footer section
|
|
25
31
|
* @csspart close-button - The close button element
|
|
26
32
|
*
|
|
33
|
+
* @event plus-modal-open - Emitted after the modal has opened
|
|
34
|
+
* @event plus-modal-close - Emitted after the modal has closed
|
|
35
|
+
* @event plus-modal-before-open - Emitted before the modal opens (cancelable)
|
|
36
|
+
* @event plus-modal-before-close - Emitted before the modal closes (cancelable)
|
|
37
|
+
*
|
|
27
38
|
* @example
|
|
28
39
|
* ```html
|
|
29
|
-
*
|
|
40
|
+
* <!-- Basic usage -->
|
|
41
|
+
* <plus-modal is-open>
|
|
30
42
|
* <div slot="header">Modal Title</div>
|
|
31
43
|
* <div slot="body">Modal Content</div>
|
|
32
44
|
* <div slot="footer">
|
|
33
|
-
* <button>
|
|
45
|
+
* <button data-dismiss>Close</button>
|
|
34
46
|
* </div>
|
|
35
47
|
* </plus-modal>
|
|
48
|
+
*
|
|
49
|
+
* <!-- Full screen modal -->
|
|
50
|
+
* <plus-modal full-screen>
|
|
51
|
+
* <div slot="header">Full Screen</div>
|
|
52
|
+
* <p>Content here</p>
|
|
53
|
+
* </plus-modal>
|
|
54
|
+
*
|
|
55
|
+
* <!-- Static backdrop (shake on outside click) -->
|
|
56
|
+
* <plus-modal backdrop="static">
|
|
57
|
+
* <div slot="header">Can't Close Outside</div>
|
|
58
|
+
* <p>Must use close button</p>
|
|
59
|
+
* </plus-modal>
|
|
36
60
|
* ```
|
|
37
61
|
*/
|
|
38
62
|
class PlusModal extends Tailwind {
|
|
39
63
|
constructor() {
|
|
40
|
-
super();
|
|
64
|
+
super(...arguments);
|
|
41
65
|
/**
|
|
42
66
|
* The size of the modal
|
|
43
67
|
* @type {'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full'}
|
|
@@ -45,6 +69,13 @@ class PlusModal extends Tailwind {
|
|
|
45
69
|
* @attr size
|
|
46
70
|
*/
|
|
47
71
|
this.size = 'md';
|
|
72
|
+
/**
|
|
73
|
+
* The placement of the modal on the screen
|
|
74
|
+
* @type {'center' | 'top'}
|
|
75
|
+
* @default 'center'
|
|
76
|
+
* @attr placement
|
|
77
|
+
*/
|
|
78
|
+
this.placement = 'center';
|
|
48
79
|
/**
|
|
49
80
|
* Whether the modal is open
|
|
50
81
|
* @type {boolean}
|
|
@@ -59,6 +90,23 @@ class PlusModal extends Tailwind {
|
|
|
59
90
|
* @attr full-width
|
|
60
91
|
*/
|
|
61
92
|
this.fullWidth = false;
|
|
93
|
+
/**
|
|
94
|
+
* Makes the modal take the full screen (100vw x 100vh, no border radius)
|
|
95
|
+
* @type {boolean}
|
|
96
|
+
* @default false
|
|
97
|
+
* @attr full-screen
|
|
98
|
+
*/
|
|
99
|
+
this.fullScreen = false;
|
|
100
|
+
/**
|
|
101
|
+
* Controls backdrop behavior
|
|
102
|
+
* - true: Shows backdrop, modal can be closed by clicking outside
|
|
103
|
+
* - false: No backdrop
|
|
104
|
+
* - 'static': Shows backdrop but prevents closing by clicking outside (triggers shake animation)
|
|
105
|
+
* @type {boolean | 'static'}
|
|
106
|
+
* @default true
|
|
107
|
+
* @attr backdrop
|
|
108
|
+
*/
|
|
109
|
+
this.backdrop = true;
|
|
62
110
|
/**
|
|
63
111
|
* Whether the modal should close when clicking the backdrop
|
|
64
112
|
* @type {boolean}
|
|
@@ -73,6 +121,20 @@ class PlusModal extends Tailwind {
|
|
|
73
121
|
* @attr close-on-esc
|
|
74
122
|
*/
|
|
75
123
|
this.closeOnEsc = true;
|
|
124
|
+
/**
|
|
125
|
+
* Hides the header section completely
|
|
126
|
+
* @type {boolean}
|
|
127
|
+
* @default false
|
|
128
|
+
* @attr no-header
|
|
129
|
+
*/
|
|
130
|
+
this.noHeader = false;
|
|
131
|
+
/**
|
|
132
|
+
* Hides the footer section completely
|
|
133
|
+
* @type {boolean}
|
|
134
|
+
* @default false
|
|
135
|
+
* @attr no-footer
|
|
136
|
+
*/
|
|
137
|
+
this.noFooter = false;
|
|
76
138
|
/**
|
|
77
139
|
* The duration of the animation in milliseconds
|
|
78
140
|
* @type {number}
|
|
@@ -81,118 +143,283 @@ class PlusModal extends Tailwind {
|
|
|
81
143
|
*/
|
|
82
144
|
this.animationDuration = 300;
|
|
83
145
|
this.isAnimating = false;
|
|
84
|
-
this.
|
|
146
|
+
this.shake = false;
|
|
85
147
|
}
|
|
86
148
|
connectedCallback() {
|
|
87
149
|
super.connectedCallback();
|
|
88
|
-
this.addEventListener('plus-modal-before-
|
|
89
|
-
this.addEventListener('plus-modal-before-
|
|
150
|
+
this.addEventListener('plus-modal-before-open', this.handleBeforeOpen);
|
|
151
|
+
this.addEventListener('plus-modal-before-close', this.handleBeforeClose);
|
|
152
|
+
}
|
|
153
|
+
disconnectedCallback() {
|
|
154
|
+
super.disconnectedCallback();
|
|
155
|
+
this.removeEventListener('plus-modal-before-open', this.handleBeforeOpen);
|
|
156
|
+
this.removeEventListener('plus-modal-before-close', this.handleBeforeClose);
|
|
157
|
+
if (this.dialogRef && this.isOpen) {
|
|
158
|
+
this.dialogRef.close();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
firstUpdated() {
|
|
162
|
+
if (this.isOpen && this.dialogRef) {
|
|
163
|
+
this.dialogRef.showModal();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
updated(changedProperties) {
|
|
167
|
+
super.updated(changedProperties);
|
|
168
|
+
if (changedProperties.has('isOpen')) {
|
|
169
|
+
if (this.isOpen) {
|
|
170
|
+
this.handleOpenChange();
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
this.handleCloseChange();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
90
176
|
}
|
|
91
177
|
/**
|
|
92
|
-
*
|
|
93
|
-
* @returns {void}
|
|
178
|
+
* Shows the modal with animation
|
|
179
|
+
* @returns {Promise<void>}
|
|
94
180
|
*/
|
|
95
|
-
|
|
96
|
-
if (this.isAnimating)
|
|
181
|
+
async show() {
|
|
182
|
+
if (this.isAnimating || this.isOpen)
|
|
97
183
|
return;
|
|
98
|
-
this.
|
|
184
|
+
this.isOpen = true;
|
|
99
185
|
}
|
|
100
|
-
|
|
101
|
-
|
|
186
|
+
/**
|
|
187
|
+
* Hides the modal with animation
|
|
188
|
+
* @returns {Promise<void>}
|
|
189
|
+
*/
|
|
190
|
+
async hide() {
|
|
191
|
+
if (this.isAnimating || !this.isOpen)
|
|
192
|
+
return;
|
|
102
193
|
this.isOpen = false;
|
|
103
|
-
setTimeout(() => {
|
|
104
|
-
this.isAnimating = false;
|
|
105
|
-
this.emit('plus-modal-hide');
|
|
106
|
-
}, this.animationDuration);
|
|
107
194
|
}
|
|
108
195
|
/**
|
|
109
|
-
*
|
|
110
|
-
* @returns {void}
|
|
196
|
+
* Toggles the modal open/closed state
|
|
197
|
+
* @returns {Promise<void>}
|
|
111
198
|
*/
|
|
112
|
-
|
|
113
|
-
if (this.
|
|
199
|
+
async toggle() {
|
|
200
|
+
if (this.isOpen) {
|
|
201
|
+
await this.hide();
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
await this.show();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
async handleOpenChange() {
|
|
208
|
+
this.isAnimating = true;
|
|
209
|
+
const event = this.emit('plus-modal-before-open', { cancelable: true });
|
|
210
|
+
if (event.defaultPrevented) {
|
|
211
|
+
this.isOpen = false;
|
|
212
|
+
this.isAnimating = false;
|
|
114
213
|
return;
|
|
115
|
-
|
|
214
|
+
}
|
|
215
|
+
if (this.dialogRef) {
|
|
216
|
+
this.dialogRef.showModal();
|
|
217
|
+
// Small delay for animation
|
|
218
|
+
await new Promise(resolve => setTimeout(resolve, 50));
|
|
219
|
+
this.isAnimating = false;
|
|
220
|
+
this.emit('plus-modal-open');
|
|
221
|
+
}
|
|
116
222
|
}
|
|
117
|
-
|
|
223
|
+
async handleCloseChange() {
|
|
118
224
|
this.isAnimating = true;
|
|
119
|
-
this.
|
|
120
|
-
|
|
225
|
+
const event = this.emit('plus-modal-before-close', { cancelable: true });
|
|
226
|
+
if (event.defaultPrevented) {
|
|
227
|
+
this.isOpen = true;
|
|
121
228
|
this.isAnimating = false;
|
|
122
|
-
|
|
123
|
-
}, this.animationDuration);
|
|
124
|
-
if (this.closeOnEsc) {
|
|
125
|
-
document.addEventListener('keydown', this.keydownHandler);
|
|
229
|
+
return;
|
|
126
230
|
}
|
|
231
|
+
// Wait for animation before closing
|
|
232
|
+
await new Promise(resolve => setTimeout(resolve, this.animationDuration));
|
|
233
|
+
if (this.dialogRef) {
|
|
234
|
+
this.dialogRef.close();
|
|
235
|
+
}
|
|
236
|
+
this.isAnimating = false;
|
|
237
|
+
this.emit('plus-modal-close');
|
|
127
238
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
239
|
+
handleBeforeOpen() {
|
|
240
|
+
// Hook for internal use if needed
|
|
241
|
+
}
|
|
242
|
+
handleBeforeClose() {
|
|
243
|
+
// Hook for internal use if needed
|
|
244
|
+
}
|
|
245
|
+
handleBackdropClick(e) {
|
|
246
|
+
const target = e.target;
|
|
247
|
+
// Check if click is on the container (backdrop area), not on modal content
|
|
248
|
+
if (target.getAttribute('part') === 'container') {
|
|
249
|
+
if (this.backdrop === 'static') {
|
|
250
|
+
this.shakeModal();
|
|
251
|
+
}
|
|
252
|
+
else if (this.closeOnBackdrop) {
|
|
253
|
+
this.hide();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
handleDialogCancel(e) {
|
|
258
|
+
e.preventDefault();
|
|
259
|
+
if (this.closeOnEsc) {
|
|
260
|
+
if (this.backdrop === 'static') {
|
|
261
|
+
this.shakeModal();
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
this.hide();
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
else if (this.backdrop === 'static') {
|
|
268
|
+
this.shakeModal();
|
|
269
|
+
}
|
|
136
270
|
}
|
|
137
271
|
handleKeydown(e) {
|
|
138
|
-
if (e.key === 'Escape' && this.
|
|
139
|
-
this
|
|
272
|
+
if (e.key === 'Escape' && this.isOpen) {
|
|
273
|
+
// Only handle ESC if this is the topmost modal
|
|
274
|
+
const openModals = Array.from(document.querySelectorAll('plus-modal[is-open]'));
|
|
275
|
+
const topModal = openModals[openModals.length - 1];
|
|
276
|
+
if (topModal !== this) {
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
e.preventDefault();
|
|
280
|
+
if (this.closeOnEsc) {
|
|
281
|
+
if (this.backdrop === 'static') {
|
|
282
|
+
this.shakeModal();
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
this.hide();
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
else if (this.backdrop === 'static') {
|
|
289
|
+
this.shakeModal();
|
|
290
|
+
}
|
|
140
291
|
}
|
|
141
292
|
}
|
|
142
|
-
|
|
143
|
-
//
|
|
144
|
-
|
|
293
|
+
handleClick(e) {
|
|
294
|
+
// Stop propagation to prevent backdrop click
|
|
295
|
+
e.stopPropagation();
|
|
296
|
+
// Use composedPath to work with shadow DOM and slots
|
|
297
|
+
const path = e.composedPath();
|
|
298
|
+
const dismissElement = path.find(el => el.hasAttribute?.('data-dismiss'));
|
|
299
|
+
const closeModalElement = path.find(el => el.hasAttribute?.('data-close-modal'));
|
|
300
|
+
if (dismissElement) {
|
|
145
301
|
this.hide();
|
|
302
|
+
e.preventDefault();
|
|
303
|
+
}
|
|
304
|
+
else if (closeModalElement) {
|
|
305
|
+
const modalId = closeModalElement.getAttribute('data-close-modal');
|
|
306
|
+
// If modalId matches this modal's id, close it
|
|
307
|
+
if (!modalId || modalId === this.id) {
|
|
308
|
+
this.hide();
|
|
309
|
+
e.preventDefault();
|
|
310
|
+
}
|
|
146
311
|
}
|
|
147
312
|
}
|
|
313
|
+
shakeModal() {
|
|
314
|
+
this.shake = true;
|
|
315
|
+
setTimeout(() => {
|
|
316
|
+
this.shake = false;
|
|
317
|
+
}, this.animationDuration);
|
|
318
|
+
}
|
|
319
|
+
getModalStyle() {
|
|
320
|
+
if (this.fullScreen) {
|
|
321
|
+
return {
|
|
322
|
+
width: '100vw',
|
|
323
|
+
height: '100vh',
|
|
324
|
+
maxWidth: 'none',
|
|
325
|
+
maxHeight: 'none',
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
if (this.fullWidth) {
|
|
329
|
+
return {
|
|
330
|
+
width: '100%',
|
|
331
|
+
maxWidth: '100%',
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
const widths = {
|
|
335
|
+
sm: '400px',
|
|
336
|
+
md: '600px',
|
|
337
|
+
lg: '800px',
|
|
338
|
+
xl: '1024px',
|
|
339
|
+
'2xl': '1200px',
|
|
340
|
+
full: '100%',
|
|
341
|
+
};
|
|
342
|
+
return {
|
|
343
|
+
width: widths[this.size],
|
|
344
|
+
maxWidth: this.fullScreen ? 'none' : '90vw',
|
|
345
|
+
maxHeight: this.fullScreen ? 'none' : '90vh',
|
|
346
|
+
};
|
|
347
|
+
}
|
|
148
348
|
render() {
|
|
149
|
-
const {
|
|
150
|
-
|
|
349
|
+
const { dialog, container, modal, header, headerContent, body, footer, closeButton, } = modalStyle({
|
|
350
|
+
open: this.isOpen,
|
|
351
|
+
placement: this.placement,
|
|
352
|
+
size: this.size,
|
|
353
|
+
fullScreen: this.fullScreen,
|
|
354
|
+
shake: this.shake,
|
|
355
|
+
noHeader: this.noHeader,
|
|
356
|
+
noFooter: this.noFooter,
|
|
357
|
+
fullWidth: this.fullWidth,
|
|
358
|
+
});
|
|
151
359
|
return x `
|
|
152
|
-
<
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
360
|
+
<dialog
|
|
361
|
+
part="dialog"
|
|
362
|
+
class=${dialog()}
|
|
363
|
+
@click=${this.handleBackdropClick}
|
|
364
|
+
@cancel=${this.handleDialogCancel}
|
|
365
|
+
@keydown=${this.handleKeydown}
|
|
156
366
|
aria-modal="true"
|
|
157
|
-
aria-hidden=${!isOpen}
|
|
158
|
-
aria-label="Modal"
|
|
159
367
|
>
|
|
160
368
|
<div
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
>
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
369
|
+
part="container"
|
|
370
|
+
class=${container()}
|
|
371
|
+
>
|
|
372
|
+
<div
|
|
373
|
+
part="modal"
|
|
374
|
+
class=${modal()}
|
|
375
|
+
style=${o(this.getModalStyle())}
|
|
376
|
+
role="document"
|
|
377
|
+
@click=${this.handleClick}
|
|
378
|
+
>
|
|
379
|
+
${!this.noHeader ? x `
|
|
380
|
+
<div part="header" class=${header()}>
|
|
381
|
+
<div part="header-content" class=${headerContent()}>
|
|
382
|
+
<slot name="header"></slot>
|
|
383
|
+
</div>
|
|
384
|
+
<slot name="close">
|
|
385
|
+
<button
|
|
386
|
+
part="close-button"
|
|
387
|
+
class=${closeButton()}
|
|
388
|
+
@click=${() => this.hide()}
|
|
389
|
+
aria-label="Close modal"
|
|
390
|
+
type="button"
|
|
391
|
+
>
|
|
392
|
+
<plus-icon icon-name="xmark"></plus-icon>
|
|
393
|
+
</button>
|
|
394
|
+
</slot>
|
|
395
|
+
</div>
|
|
396
|
+
` : ''}
|
|
397
|
+
|
|
398
|
+
<div part="body" class=${body()}>
|
|
181
399
|
<slot name="body"></slot>
|
|
182
400
|
<slot></slot>
|
|
183
401
|
</div>
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
402
|
+
|
|
403
|
+
${!this.noFooter ? x `
|
|
404
|
+
<div part="footer" class=${footer()}>
|
|
405
|
+
<slot name="footer"></slot>
|
|
406
|
+
</div>
|
|
407
|
+
` : ''}
|
|
187
408
|
</div>
|
|
188
409
|
</div>
|
|
189
|
-
</
|
|
410
|
+
</dialog>
|
|
190
411
|
`;
|
|
191
412
|
}
|
|
192
413
|
}
|
|
414
|
+
__decorate([
|
|
415
|
+
e('dialog')
|
|
416
|
+
], PlusModal.prototype, "dialogRef", void 0);
|
|
193
417
|
__decorate([
|
|
194
418
|
n({ type: String, reflect: true })
|
|
195
419
|
], PlusModal.prototype, "size", void 0);
|
|
420
|
+
__decorate([
|
|
421
|
+
n({ type: String, reflect: true })
|
|
422
|
+
], PlusModal.prototype, "placement", void 0);
|
|
196
423
|
__decorate([
|
|
197
424
|
n({
|
|
198
425
|
type: Boolean,
|
|
@@ -209,6 +436,17 @@ __decorate([
|
|
|
209
436
|
converter: booleanConverter,
|
|
210
437
|
})
|
|
211
438
|
], PlusModal.prototype, "fullWidth", void 0);
|
|
439
|
+
__decorate([
|
|
440
|
+
n({
|
|
441
|
+
type: Boolean,
|
|
442
|
+
reflect: true,
|
|
443
|
+
attribute: 'full-screen',
|
|
444
|
+
converter: booleanConverter,
|
|
445
|
+
})
|
|
446
|
+
], PlusModal.prototype, "fullScreen", void 0);
|
|
447
|
+
__decorate([
|
|
448
|
+
n({ type: String, reflect: true })
|
|
449
|
+
], PlusModal.prototype, "backdrop", void 0);
|
|
212
450
|
__decorate([
|
|
213
451
|
n({
|
|
214
452
|
type: Boolean,
|
|
@@ -225,11 +463,30 @@ __decorate([
|
|
|
225
463
|
attribute: 'close-on-esc',
|
|
226
464
|
})
|
|
227
465
|
], PlusModal.prototype, "closeOnEsc", void 0);
|
|
466
|
+
__decorate([
|
|
467
|
+
n({
|
|
468
|
+
type: Boolean,
|
|
469
|
+
reflect: true,
|
|
470
|
+
attribute: 'no-header',
|
|
471
|
+
converter: booleanConverter,
|
|
472
|
+
})
|
|
473
|
+
], PlusModal.prototype, "noHeader", void 0);
|
|
474
|
+
__decorate([
|
|
475
|
+
n({
|
|
476
|
+
type: Boolean,
|
|
477
|
+
reflect: true,
|
|
478
|
+
attribute: 'no-footer',
|
|
479
|
+
converter: booleanConverter,
|
|
480
|
+
})
|
|
481
|
+
], PlusModal.prototype, "noFooter", void 0);
|
|
228
482
|
__decorate([
|
|
229
483
|
n({ type: Number, reflect: true, attribute: 'animation-duration' })
|
|
230
484
|
], PlusModal.prototype, "animationDuration", void 0);
|
|
231
485
|
__decorate([
|
|
232
486
|
r()
|
|
233
487
|
], PlusModal.prototype, "isAnimating", void 0);
|
|
488
|
+
__decorate([
|
|
489
|
+
r()
|
|
490
|
+
], PlusModal.prototype, "shake", void 0);
|
|
234
491
|
|
|
235
492
|
export { PlusModal, PlusModal as default };
|