@operato/popup 2.0.0-beta.30 → 2.0.0-beta.31
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/CHANGELOG.md +9 -0
- package/dist/src/ox-popup-list.js +2 -2
- package/dist/src/ox-popup-list.js.map +1 -1
- package/dist/src/ox-popup.d.ts +3 -2
- package/dist/src/ox-popup.js +12 -8
- package/dist/src/ox-popup.js.map +1 -1
- package/dist/src/ox-prompt.d.ts +7 -1
- package/dist/src/ox-prompt.js +12 -3
- package/dist/src/ox-prompt.js.map +1 -1
- package/dist/stories/ox-popup-list-sortable.stories.d.ts +2 -2
- package/dist/stories/ox-popup-list-sortable.stories.js +3 -3
- package/dist/stories/ox-popup-list-sortable.stories.js.map +1 -1
- package/dist/stories/ox-prompt-icon.stories.d.ts +2 -2
- package/dist/stories/ox-prompt-icon.stories.js +12 -8
- package/dist/stories/ox-prompt-icon.stories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/ox-popup-list.ts +2 -2
- package/src/ox-popup.ts +12 -6
- package/src/ox-prompt.ts +11 -2
- package/stories/ox-popup-list-sortable.stories.ts +4 -4
- package/stories/ox-prompt-icon.stories.ts +13 -10
package/src/ox-popup.ts
CHANGED
|
@@ -34,6 +34,7 @@ export class OxPopup extends LitElement {
|
|
|
34
34
|
|
|
35
35
|
:host([active]) {
|
|
36
36
|
display: flex;
|
|
37
|
+
flex-direction: column;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
:host(*:focus) {
|
|
@@ -42,7 +43,7 @@ export class OxPopup extends LitElement {
|
|
|
42
43
|
`
|
|
43
44
|
]
|
|
44
45
|
|
|
45
|
-
@property({ type: Boolean })
|
|
46
|
+
@property({ type: Boolean, attribute: 'prevent-close-on-blur' }) preventCloseOnBlur: boolean = false
|
|
46
47
|
|
|
47
48
|
@state() _parent: Element | null = null
|
|
48
49
|
|
|
@@ -57,8 +58,8 @@ export class OxPopup extends LitElement {
|
|
|
57
58
|
|
|
58
59
|
if (!this.contains(to)) {
|
|
59
60
|
/* 분명히 내 범위가 아닌 엘리먼트로 포커스가 옮겨졌다면, ox-popup은 닫혀야 한다. */
|
|
60
|
-
// @ts-ignore for
|
|
61
|
-
!this.
|
|
61
|
+
// @ts-ignore for preventCloseOnBlur
|
|
62
|
+
!this.preventCloseOnBlur && !window.POPUP_DEBUG && this.close()
|
|
62
63
|
}
|
|
63
64
|
}.bind(this)
|
|
64
65
|
|
|
@@ -104,8 +105,8 @@ export class OxPopup extends LitElement {
|
|
|
104
105
|
}.bind(this)
|
|
105
106
|
|
|
106
107
|
protected _onwindowblur: (e: Event) => void = function (this: OxPopup, e: Event) {
|
|
107
|
-
// @ts-ignore for
|
|
108
|
-
!this.
|
|
108
|
+
// @ts-ignore for preventCloseOnBlur
|
|
109
|
+
!this.preventCloseOnBlur && !window.POPUP_DEBUG && this.close()
|
|
109
110
|
}.bind(this)
|
|
110
111
|
|
|
111
112
|
connectedCallback() {
|
|
@@ -143,7 +144,8 @@ export class OxPopup extends LitElement {
|
|
|
143
144
|
width,
|
|
144
145
|
height,
|
|
145
146
|
parent,
|
|
146
|
-
style
|
|
147
|
+
style,
|
|
148
|
+
preventCloseOnBlur
|
|
147
149
|
}: {
|
|
148
150
|
template: unknown
|
|
149
151
|
top?: number
|
|
@@ -154,9 +156,13 @@ export class OxPopup extends LitElement {
|
|
|
154
156
|
height?: string
|
|
155
157
|
parent?: Element | null
|
|
156
158
|
style?: string
|
|
159
|
+
preventCloseOnBlur?: boolean
|
|
157
160
|
}): OxPopup {
|
|
158
161
|
const owner = parent || document.body
|
|
159
162
|
const target = document.createElement('ox-popup') as OxPopup
|
|
163
|
+
if (preventCloseOnBlur) {
|
|
164
|
+
target.preventCloseOnBlur = preventCloseOnBlur
|
|
165
|
+
}
|
|
160
166
|
if (style) {
|
|
161
167
|
target.style.cssText = style
|
|
162
168
|
}
|
package/src/ox-prompt.ts
CHANGED
|
@@ -164,6 +164,11 @@ export class OxPrompt extends LitElement {
|
|
|
164
164
|
*/
|
|
165
165
|
@property({ type: Object }) cancelButton?: { text: string; color?: string }
|
|
166
166
|
|
|
167
|
+
/**
|
|
168
|
+
* Prevents the popup from closing when it loses focus (blur event).
|
|
169
|
+
*/
|
|
170
|
+
@property({ type: Boolean, attribute: 'prevent-close-on-blur' }) preventCloseOnBlur: boolean = false
|
|
171
|
+
|
|
167
172
|
/**
|
|
168
173
|
* A callback function called when the popup is closed, providing the result of the user's interaction.
|
|
169
174
|
*/
|
|
@@ -225,7 +230,7 @@ export class OxPrompt extends LitElement {
|
|
|
225
230
|
if (!this.contains(to)) {
|
|
226
231
|
/* 분명히 내 범위가 아닌 엘리먼트로 포커스가 옮겨졌다면, ox-prompt은 닫혀야 한다. */
|
|
227
232
|
// @ts-ignore for debug
|
|
228
|
-
if (window.POPUP_DEBUG) {
|
|
233
|
+
if (this.preventCloseOnBlur || window.POPUP_DEBUG) {
|
|
229
234
|
return
|
|
230
235
|
}
|
|
231
236
|
|
|
@@ -280,7 +285,7 @@ export class OxPrompt extends LitElement {
|
|
|
280
285
|
|
|
281
286
|
protected _onwindowblur: (e: Event) => void = function (this: OxPrompt, e: Event) {
|
|
282
287
|
// @ts-ignore for debug
|
|
283
|
-
if (window.POPUP_DEBUG) {
|
|
288
|
+
if (this.preventCloseOnBlur || window.POPUP_DEBUG) {
|
|
284
289
|
return
|
|
285
290
|
}
|
|
286
291
|
|
|
@@ -327,6 +332,7 @@ export class OxPrompt extends LitElement {
|
|
|
327
332
|
* @param {string} [options.width] - The maximum width of the popup (CSS string).
|
|
328
333
|
* @param {string} [options.height] - The maximum height of the popup (CSS string).
|
|
329
334
|
* @param {Element | null} [options.parent] - The parent element to which the popup should be attached. If not provided, it will be attached to the document body.
|
|
335
|
+
* @param {boolean} [options.preventCloseOnBlur] - Prevents the popup from closing when it loses focus (blur event).
|
|
330
336
|
* @param {(result: { value: boolean }) => void} [options.callback] - A callback function that will be invoked when the user interacts with the popup, providing the result of the interaction.
|
|
331
337
|
* @returns {Promise<boolean>} A Promise that resolves based on user interaction with the popup.
|
|
332
338
|
*/
|
|
@@ -346,6 +352,7 @@ export class OxPrompt extends LitElement {
|
|
|
346
352
|
width,
|
|
347
353
|
height,
|
|
348
354
|
parent,
|
|
355
|
+
preventCloseOnBlur,
|
|
349
356
|
callback
|
|
350
357
|
}: {
|
|
351
358
|
template?: unknown
|
|
@@ -363,6 +370,7 @@ export class OxPrompt extends LitElement {
|
|
|
363
370
|
width?: string
|
|
364
371
|
height?: string
|
|
365
372
|
parent?: Element | null
|
|
373
|
+
preventCloseOnBlur?: boolean
|
|
366
374
|
callback?: (result: { value: boolean }) => void
|
|
367
375
|
}): Promise<boolean> {
|
|
368
376
|
const owner = parent || document.body
|
|
@@ -375,6 +383,7 @@ export class OxPrompt extends LitElement {
|
|
|
375
383
|
target.footer = footer
|
|
376
384
|
target.confirmButton = confirmButton
|
|
377
385
|
target.cancelButton = cancelButton
|
|
386
|
+
target.preventCloseOnBlur = !!preventCloseOnBlur
|
|
378
387
|
|
|
379
388
|
render(template, target)
|
|
380
389
|
|
|
@@ -12,7 +12,7 @@ export default {
|
|
|
12
12
|
title: 'sortable OxPopupList',
|
|
13
13
|
component: 'ox-popup-list',
|
|
14
14
|
argTypes: {
|
|
15
|
-
|
|
15
|
+
preventCloseOnBlur: { control: 'boolean' },
|
|
16
16
|
theme: { control: 'select', options: ['light', 'dark'] }
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -24,7 +24,7 @@ interface Story<T> {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
interface ArgTypes {
|
|
27
|
-
|
|
27
|
+
preventCloseOnBlur: boolean
|
|
28
28
|
theme?: 'light' | 'dark'
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -91,7 +91,7 @@ const columns = [
|
|
|
91
91
|
}
|
|
92
92
|
]
|
|
93
93
|
|
|
94
|
-
const Template: Story<ArgTypes> = ({
|
|
94
|
+
const Template: Story<ArgTypes> = ({ preventCloseOnBlur, theme }: ArgTypes) => html`
|
|
95
95
|
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet" />
|
|
96
96
|
|
|
97
97
|
<link href="/themes/light.css" rel="stylesheet" />
|
|
@@ -190,7 +190,7 @@ const Template: Story<ArgTypes> = ({ debug, theme }: ArgTypes) => html`
|
|
|
190
190
|
}}
|
|
191
191
|
multiple
|
|
192
192
|
sortable
|
|
193
|
-
?
|
|
193
|
+
?prevent-close-on-blur=${preventCloseOnBlur}
|
|
194
194
|
>
|
|
195
195
|
<div slot="header" titler>Plain Text <md-outlined-button>save</md-outlined-button></div>
|
|
196
196
|
${columns.map(
|
|
@@ -9,7 +9,7 @@ export default {
|
|
|
9
9
|
component: 'ox-prompt',
|
|
10
10
|
argTypes: {
|
|
11
11
|
type: { control: 'select', options: ['success', 'error', 'warning', 'info', 'question'] },
|
|
12
|
-
|
|
12
|
+
preventCloseOnBlur: { control: 'boolean' },
|
|
13
13
|
theme: { control: 'select', options: ['light', 'dark'] }
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -22,7 +22,7 @@ interface Story<T> {
|
|
|
22
22
|
|
|
23
23
|
interface ArgTypes {
|
|
24
24
|
type: 'success' | 'error' | 'warning' | 'info' | 'question'
|
|
25
|
-
|
|
25
|
+
preventCloseOnBlur: boolean
|
|
26
26
|
theme?: 'light' | 'dark'
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -30,23 +30,22 @@ function popup(
|
|
|
30
30
|
e: MouseEvent,
|
|
31
31
|
type: 'success' | 'error' | 'warning' | 'info' | 'question' = 'warning',
|
|
32
32
|
theme: 'light' | 'dark',
|
|
33
|
-
|
|
33
|
+
preventCloseOnBlur: boolean
|
|
34
34
|
) {
|
|
35
35
|
const noImage = new URL('/assets/images/no-image.png', import.meta.url).href
|
|
36
36
|
|
|
37
|
-
//@ts-ignore
|
|
38
|
-
window.POPUP_DEBUG = debug
|
|
39
|
-
|
|
40
37
|
OxPrompt.open({
|
|
41
38
|
title: 'Are you sure ?',
|
|
42
39
|
text: 'Are you sure to exit this page ?',
|
|
43
40
|
type,
|
|
41
|
+
icon: noImage,
|
|
44
42
|
confirmButton: { text: 'Confirm' },
|
|
45
|
-
cancelButton: { text: 'Cancel' }
|
|
43
|
+
cancelButton: { text: 'Cancel' },
|
|
44
|
+
preventCloseOnBlur
|
|
46
45
|
})
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
const Template: Story<ArgTypes> = ({ type,
|
|
48
|
+
const Template: Story<ArgTypes> = ({ type, preventCloseOnBlur, theme = 'light' }: ArgTypes) => html`
|
|
50
49
|
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet" />
|
|
51
50
|
|
|
52
51
|
<link href="/themes/light.css" rel="stylesheet" />
|
|
@@ -85,7 +84,11 @@ const Template: Story<ArgTypes> = ({ type, debug, theme = 'light' }: ArgTypes) =
|
|
|
85
84
|
document.body.classList.add('${theme}')
|
|
86
85
|
</script>
|
|
87
86
|
|
|
88
|
-
<div
|
|
87
|
+
<div
|
|
88
|
+
id="place"
|
|
89
|
+
@click=${(e: MouseEvent) => popup(e, type, theme, preventCloseOnBlur)}
|
|
90
|
+
class="md-typescale-display-medium"
|
|
91
|
+
>
|
|
89
92
|
Click this to prompt image
|
|
90
93
|
</div>
|
|
91
94
|
`
|
|
@@ -93,5 +96,5 @@ const Template: Story<ArgTypes> = ({ type, debug, theme = 'light' }: ArgTypes) =
|
|
|
93
96
|
export const Regular = Template.bind({})
|
|
94
97
|
Regular.args = {
|
|
95
98
|
type: 'warning',
|
|
96
|
-
|
|
99
|
+
preventCloseOnBlur: true
|
|
97
100
|
}
|