@plusui/library 0.1.15 → 0.1.17
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 +343 -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 +342 -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-DKbfGhXu.js → if-defined-DBB3AQZw.js} +1 -1
- package/dist/index.css +1 -1
- package/dist/{live-CtqYa7Iz.js → live-Db5nLVo0.js} +1 -1
- package/dist/{property-DhJ1LIGX.js → property-C9Hzx3kj.js} +1 -1
- package/dist/{query-CJZ9rve2.js → query-RewOgxYG.js} +1 -1
- package/dist/{query-assigned-elements-BTKIEABn.js → query-assigned-elements-DY-CICub.js} +1 -1
- package/dist/{state-BJT7gLGV.js → state-B4zcCODl.js} +1 -1
- package/dist/{style-map-4vJ38bCf.js → style-map-sUMHadXp.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 +409 -124
- package/public/react/index.d.ts +145 -33
- package/public/react/index.js +433 -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-DGCiKnca.js +0 -1
- package/cdn/global-GTfSG3gU.js +0 -31
- /package/dist/{base-ByZpKIDU.js → base-CBi-OLn2.js} +0 -0
- /package/dist/{directive-rJcjnQEi.js → directive-B_gs7lGG.js} +0 -0
- /package/dist/{floating-ui.dom-CnRf1aAR.js → floating-ui.dom-Cv67XeEd.js} +0 -0
- /package/dist/{index-DUwBBqWm.js → index-Cobjj9Q1.js} +0 -0
- /package/dist/{lit-element-Bu7TYzc7.js → lit-element-naXdLm94.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,286 @@ 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
|
+
// Use composedPath to work with shadow DOM and slots
|
|
295
|
+
const path = e.composedPath();
|
|
296
|
+
const dismissElement = path.find(el => el.hasAttribute?.('data-dismiss'));
|
|
297
|
+
const closeModalElement = path.find(el => el.hasAttribute?.('data-close-modal'));
|
|
298
|
+
if (dismissElement) {
|
|
299
|
+
// Stop propagation only when dismissing the modal
|
|
300
|
+
e.stopPropagation();
|
|
301
|
+
e.preventDefault();
|
|
145
302
|
this.hide();
|
|
146
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
|
+
// Stop propagation only when closing the modal
|
|
309
|
+
e.stopPropagation();
|
|
310
|
+
e.preventDefault();
|
|
311
|
+
this.hide();
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
// Don't stop propagation for normal clicks - let them bubble to child elements
|
|
315
|
+
}
|
|
316
|
+
shakeModal() {
|
|
317
|
+
this.shake = true;
|
|
318
|
+
setTimeout(() => {
|
|
319
|
+
this.shake = false;
|
|
320
|
+
}, this.animationDuration);
|
|
321
|
+
}
|
|
322
|
+
getModalStyle() {
|
|
323
|
+
if (this.fullScreen) {
|
|
324
|
+
return {
|
|
325
|
+
width: '100vw',
|
|
326
|
+
height: '100vh',
|
|
327
|
+
maxWidth: 'none',
|
|
328
|
+
maxHeight: 'none',
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
if (this.fullWidth) {
|
|
332
|
+
return {
|
|
333
|
+
width: '100%',
|
|
334
|
+
maxWidth: '100%',
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
const widths = {
|
|
338
|
+
sm: '400px',
|
|
339
|
+
md: '600px',
|
|
340
|
+
lg: '800px',
|
|
341
|
+
xl: '1024px',
|
|
342
|
+
'2xl': '1200px',
|
|
343
|
+
full: '100%',
|
|
344
|
+
};
|
|
345
|
+
return {
|
|
346
|
+
width: widths[this.size],
|
|
347
|
+
maxWidth: this.fullScreen ? 'none' : '90vw',
|
|
348
|
+
maxHeight: this.fullScreen ? 'none' : '90vh',
|
|
349
|
+
};
|
|
147
350
|
}
|
|
148
351
|
render() {
|
|
149
|
-
const {
|
|
150
|
-
|
|
352
|
+
const { dialog, container, modal, header, headerContent, body, footer, closeButton, } = modalStyle({
|
|
353
|
+
open: this.isOpen,
|
|
354
|
+
placement: this.placement,
|
|
355
|
+
size: this.size,
|
|
356
|
+
fullScreen: this.fullScreen,
|
|
357
|
+
shake: this.shake,
|
|
358
|
+
noHeader: this.noHeader,
|
|
359
|
+
noFooter: this.noFooter,
|
|
360
|
+
fullWidth: this.fullWidth,
|
|
361
|
+
});
|
|
151
362
|
return x `
|
|
152
|
-
<
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
363
|
+
<dialog
|
|
364
|
+
part="dialog"
|
|
365
|
+
class=${dialog()}
|
|
366
|
+
@click=${this.handleBackdropClick}
|
|
367
|
+
@cancel=${this.handleDialogCancel}
|
|
368
|
+
@keydown=${this.handleKeydown}
|
|
156
369
|
aria-modal="true"
|
|
157
|
-
aria-hidden=${!isOpen}
|
|
158
|
-
aria-label="Modal"
|
|
159
370
|
>
|
|
160
371
|
<div
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
>
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
372
|
+
part="container"
|
|
373
|
+
class=${container()}
|
|
374
|
+
>
|
|
375
|
+
<div
|
|
376
|
+
part="modal"
|
|
377
|
+
class=${modal()}
|
|
378
|
+
style=${o(this.getModalStyle())}
|
|
379
|
+
role="document"
|
|
380
|
+
@click=${this.handleClick}
|
|
381
|
+
>
|
|
382
|
+
${!this.noHeader ? x `
|
|
383
|
+
<div part="header" class=${header()}>
|
|
384
|
+
<div part="header-content" class=${headerContent()}>
|
|
385
|
+
<slot name="header"></slot>
|
|
386
|
+
</div>
|
|
387
|
+
<slot name="close">
|
|
388
|
+
<button
|
|
389
|
+
part="close-button"
|
|
390
|
+
class=${closeButton()}
|
|
391
|
+
@click=${() => this.hide()}
|
|
392
|
+
aria-label="Close modal"
|
|
393
|
+
type="button"
|
|
394
|
+
>
|
|
395
|
+
<plus-icon icon-name="xmark"></plus-icon>
|
|
396
|
+
</button>
|
|
397
|
+
</slot>
|
|
398
|
+
</div>
|
|
399
|
+
` : ''}
|
|
400
|
+
|
|
401
|
+
<div part="body" class=${body()}>
|
|
181
402
|
<slot name="body"></slot>
|
|
182
403
|
<slot></slot>
|
|
183
404
|
</div>
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
405
|
+
|
|
406
|
+
${!this.noFooter ? x `
|
|
407
|
+
<div part="footer" class=${footer()}>
|
|
408
|
+
<slot name="footer"></slot>
|
|
409
|
+
</div>
|
|
410
|
+
` : ''}
|
|
187
411
|
</div>
|
|
188
412
|
</div>
|
|
189
|
-
</
|
|
413
|
+
</dialog>
|
|
190
414
|
`;
|
|
191
415
|
}
|
|
192
416
|
}
|
|
417
|
+
__decorate([
|
|
418
|
+
e('dialog')
|
|
419
|
+
], PlusModal.prototype, "dialogRef", void 0);
|
|
193
420
|
__decorate([
|
|
194
421
|
n({ type: String, reflect: true })
|
|
195
422
|
], PlusModal.prototype, "size", void 0);
|
|
423
|
+
__decorate([
|
|
424
|
+
n({ type: String, reflect: true })
|
|
425
|
+
], PlusModal.prototype, "placement", void 0);
|
|
196
426
|
__decorate([
|
|
197
427
|
n({
|
|
198
428
|
type: Boolean,
|
|
@@ -209,6 +439,17 @@ __decorate([
|
|
|
209
439
|
converter: booleanConverter,
|
|
210
440
|
})
|
|
211
441
|
], PlusModal.prototype, "fullWidth", void 0);
|
|
442
|
+
__decorate([
|
|
443
|
+
n({
|
|
444
|
+
type: Boolean,
|
|
445
|
+
reflect: true,
|
|
446
|
+
attribute: 'full-screen',
|
|
447
|
+
converter: booleanConverter,
|
|
448
|
+
})
|
|
449
|
+
], PlusModal.prototype, "fullScreen", void 0);
|
|
450
|
+
__decorate([
|
|
451
|
+
n({ type: String, reflect: true })
|
|
452
|
+
], PlusModal.prototype, "backdrop", void 0);
|
|
212
453
|
__decorate([
|
|
213
454
|
n({
|
|
214
455
|
type: Boolean,
|
|
@@ -225,11 +466,30 @@ __decorate([
|
|
|
225
466
|
attribute: 'close-on-esc',
|
|
226
467
|
})
|
|
227
468
|
], PlusModal.prototype, "closeOnEsc", void 0);
|
|
469
|
+
__decorate([
|
|
470
|
+
n({
|
|
471
|
+
type: Boolean,
|
|
472
|
+
reflect: true,
|
|
473
|
+
attribute: 'no-header',
|
|
474
|
+
converter: booleanConverter,
|
|
475
|
+
})
|
|
476
|
+
], PlusModal.prototype, "noHeader", void 0);
|
|
477
|
+
__decorate([
|
|
478
|
+
n({
|
|
479
|
+
type: Boolean,
|
|
480
|
+
reflect: true,
|
|
481
|
+
attribute: 'no-footer',
|
|
482
|
+
converter: booleanConverter,
|
|
483
|
+
})
|
|
484
|
+
], PlusModal.prototype, "noFooter", void 0);
|
|
228
485
|
__decorate([
|
|
229
486
|
n({ type: Number, reflect: true, attribute: 'animation-duration' })
|
|
230
487
|
], PlusModal.prototype, "animationDuration", void 0);
|
|
231
488
|
__decorate([
|
|
232
489
|
r()
|
|
233
490
|
], PlusModal.prototype, "isAnimating", void 0);
|
|
491
|
+
__decorate([
|
|
492
|
+
r()
|
|
493
|
+
], PlusModal.prototype, "shake", void 0);
|
|
234
494
|
|
|
235
495
|
export { PlusModal, PlusModal as default };
|