@operato/popup 2.0.0-alpha.2 → 2.0.0-alpha.28
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 +36 -0
- package/dist/src/ox-floating-overlay.d.ts +65 -0
- package/dist/src/ox-floating-overlay.js +30 -1
- package/dist/src/ox-floating-overlay.js.map +1 -1
- package/dist/src/ox-popup-list.d.ts +49 -0
- package/dist/src/ox-popup-list.js +35 -0
- package/dist/src/ox-popup-list.js.map +1 -1
- package/dist/src/ox-popup-menu.d.ts +15 -1
- package/dist/src/ox-popup-menu.js +15 -1
- package/dist/src/ox-popup-menu.js.map +1 -1
- package/dist/src/ox-popup-menuitem.d.ts +28 -0
- package/dist/src/ox-popup-menuitem.js +25 -0
- package/dist/src/ox-popup-menuitem.js.map +1 -1
- package/dist/src/ox-popup.d.ts +27 -7
- package/dist/src/ox-popup.js +34 -11
- package/dist/src/ox-popup.js.map +1 -1
- package/dist/src/ox-prompt.d.ts +76 -0
- package/dist/src/ox-prompt.js +52 -0
- package/dist/src/ox-prompt.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -14
- package/src/ox-floating-overlay.ts +79 -1
- package/src/ox-popup-list.ts +52 -0
- package/src/ox-popup-menu.ts +15 -1
- package/src/ox-popup-menuitem.ts +29 -0
- package/src/ox-popup.ts +36 -13
- package/src/ox-prompt.ts +84 -0
package/src/ox-popup-list.ts
CHANGED
|
@@ -23,6 +23,9 @@ function guaranteeFocus(element: HTMLElement) {
|
|
|
23
23
|
closest?.focus()
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* A custom element representing a list-like popup menu.
|
|
28
|
+
*/
|
|
26
29
|
@customElement('ox-popup-list')
|
|
27
30
|
export class OxPopupList extends OxPopup {
|
|
28
31
|
static styles = [
|
|
@@ -129,9 +132,30 @@ export class OxPopupList extends OxPopup {
|
|
|
129
132
|
`
|
|
130
133
|
]
|
|
131
134
|
|
|
135
|
+
/**
|
|
136
|
+
* A boolean property that, when set to true, allows multiple options to be selected in the popup list.
|
|
137
|
+
* @type {boolean}
|
|
138
|
+
*/
|
|
132
139
|
@property({ type: Boolean }) multiple: boolean = false
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* An optional attribute that specifies the name of the attribute used to mark selected options in the list.
|
|
143
|
+
* @type {string|undefined}
|
|
144
|
+
*/
|
|
133
145
|
@property({ type: String, attribute: 'attr-selected' }) attrSelected?: string
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* A boolean property that, when set to true, enables the search functionality in the popup list.
|
|
149
|
+
* Users can search/filter options by typing in a search bar.
|
|
150
|
+
* @type {boolean|undefined}
|
|
151
|
+
*/
|
|
134
152
|
@property({ type: Boolean, attribute: 'with-search' }) withSearch?: boolean
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* The value(s) of the selected option(s) in the popup list.
|
|
156
|
+
* This property can be a string or an array of strings, depending on whether multiple selections are allowed.
|
|
157
|
+
* @type {string|string[]|undefined}
|
|
158
|
+
*/
|
|
135
159
|
@property({ type: String }) value?: string | string[]
|
|
136
160
|
|
|
137
161
|
@state() activeIndex?: number
|
|
@@ -284,6 +308,11 @@ export class OxPopupList extends OxPopup {
|
|
|
284
308
|
}
|
|
285
309
|
}
|
|
286
310
|
|
|
311
|
+
/**
|
|
312
|
+
* Retrieves the labels of the selected options in the popup list.
|
|
313
|
+
* If multiple selections are allowed, an array of labels is returned. Otherwise, a single label is returned.
|
|
314
|
+
* @returns {string|string[]} The label(s) of the selected option(s).
|
|
315
|
+
*/
|
|
287
316
|
public getSelectedLabels(): string | string[] {
|
|
288
317
|
const options = Array.from(this.querySelectorAll(':scope > [option]'))
|
|
289
318
|
|
|
@@ -294,6 +323,11 @@ export class OxPopupList extends OxPopup {
|
|
|
294
323
|
return this.multiple ? selected : selected[0]
|
|
295
324
|
}
|
|
296
325
|
|
|
326
|
+
/**
|
|
327
|
+
* Handles the selection of options in the popup list and dispatches a 'select' event with the selected value(s).
|
|
328
|
+
* If multiple selections are allowed, an array of selected values is dispatched; otherwise, a single value is dispatched.
|
|
329
|
+
* Also, it checks whether the selected option should remain alive and whether the popup should be closed.
|
|
330
|
+
*/
|
|
297
331
|
async select() {
|
|
298
332
|
await this.updateComplete
|
|
299
333
|
|
|
@@ -317,6 +351,13 @@ export class OxPopupList extends OxPopup {
|
|
|
317
351
|
}
|
|
318
352
|
}
|
|
319
353
|
|
|
354
|
+
/**
|
|
355
|
+
* Sets the active option within the popup list based on the given index or Element.
|
|
356
|
+
* If 'withSelect' is true, it also manages the selection state of the option.
|
|
357
|
+
*
|
|
358
|
+
* @param {number | Element | null} active - The index or Element of the option to set as active.
|
|
359
|
+
* @param {boolean | undefined} withSelect - Indicates whether to manage the selection state of the option.
|
|
360
|
+
*/
|
|
320
361
|
setActive(active: number | Element | null, withSelect?: boolean) {
|
|
321
362
|
var options = Array.from(this.querySelectorAll('[option]:not([hidden])'))
|
|
322
363
|
if (this.withSearch) {
|
|
@@ -351,6 +392,12 @@ export class OxPopupList extends OxPopup {
|
|
|
351
392
|
})
|
|
352
393
|
}
|
|
353
394
|
|
|
395
|
+
/**
|
|
396
|
+
* Overrides the 'open' method of the base class 'OxPopup' to set the initial active index
|
|
397
|
+
* when the popup list is opened. It ensures that an option is initially selected for user interaction.
|
|
398
|
+
*
|
|
399
|
+
* @param {object} params - The parameters for opening the popup, including position and size.
|
|
400
|
+
*/
|
|
354
401
|
override open(params: {
|
|
355
402
|
left?: number
|
|
356
403
|
top?: number
|
|
@@ -369,6 +416,11 @@ export class OxPopupList extends OxPopup {
|
|
|
369
416
|
}
|
|
370
417
|
}
|
|
371
418
|
|
|
419
|
+
/**
|
|
420
|
+
* Overrides the 'close' method of the base class 'OxPopup' to dispatch a custom event
|
|
421
|
+
* indicating that the popup list is being closed. This event can be used for further interactions
|
|
422
|
+
* or logic in the application.
|
|
423
|
+
*/
|
|
372
424
|
override close() {
|
|
373
425
|
if (this.hasAttribute('active')) {
|
|
374
426
|
this.dispatchEvent(
|
package/src/ox-popup-menu.ts
CHANGED
|
@@ -15,6 +15,9 @@ function focusClosest(element: HTMLElement) {
|
|
|
15
15
|
return closest
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Custom element representing a popup menu. It extends OxPopup.
|
|
20
|
+
*/
|
|
18
21
|
@customElement('ox-popup-menu')
|
|
19
22
|
export class OxPopupMenu extends OxPopup {
|
|
20
23
|
static styles = [
|
|
@@ -77,6 +80,9 @@ export class OxPopupMenu extends OxPopup {
|
|
|
77
80
|
`
|
|
78
81
|
]
|
|
79
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Property to track the index of the active menu item.
|
|
85
|
+
*/
|
|
80
86
|
@property({ type: Number }) activeIndex: number = 0
|
|
81
87
|
|
|
82
88
|
render() {
|
|
@@ -151,6 +157,10 @@ export class OxPopupMenu extends OxPopup {
|
|
|
151
157
|
}
|
|
152
158
|
}
|
|
153
159
|
|
|
160
|
+
/**
|
|
161
|
+
* Selects a menu item by dispatching a 'select' event.
|
|
162
|
+
* Closes the menu if the item doesn't have 'alive-on-select' attribute.
|
|
163
|
+
*/
|
|
154
164
|
select(menu: Element) {
|
|
155
165
|
menu.dispatchEvent(new CustomEvent('select'))
|
|
156
166
|
if (!menu.hasAttribute('alive-on-select')) {
|
|
@@ -158,6 +168,9 @@ export class OxPopupMenu extends OxPopup {
|
|
|
158
168
|
}
|
|
159
169
|
}
|
|
160
170
|
|
|
171
|
+
/**
|
|
172
|
+
* Sets the active menu item based on the index or the menu element itself.
|
|
173
|
+
*/
|
|
161
174
|
setActive(active: number | Element | null) {
|
|
162
175
|
const menus = Array.from(this.querySelectorAll(':scope > ox-popup-menuitem, :scope > [menu]'))
|
|
163
176
|
|
|
@@ -183,7 +196,8 @@ export class OxPopupMenu extends OxPopup {
|
|
|
183
196
|
}
|
|
184
197
|
|
|
185
198
|
/**
|
|
186
|
-
*
|
|
199
|
+
* Static method to open a popup menu with the provided template and position options.
|
|
200
|
+
* Creates and returns an instance of OxPopupMenu.
|
|
187
201
|
*
|
|
188
202
|
* @param {PopupOpenOptions}
|
|
189
203
|
*/
|
package/src/ox-popup-menuitem.ts
CHANGED
|
@@ -3,6 +3,10 @@ import { customElement, property, state } from 'lit/decorators.js'
|
|
|
3
3
|
|
|
4
4
|
import { OxPopupMenu } from './ox-popup-menu'
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Custom element representing a menu item within an OxPopup menu.
|
|
8
|
+
* It can contain a label and an optional submenu.
|
|
9
|
+
*/
|
|
6
10
|
@customElement('ox-popup-menuitem')
|
|
7
11
|
export class OxPopupMenuItem extends LitElement {
|
|
8
12
|
static styles = [
|
|
@@ -49,7 +53,15 @@ export class OxPopupMenuItem extends LitElement {
|
|
|
49
53
|
`
|
|
50
54
|
]
|
|
51
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Property indicating whether the menu item is active or not.
|
|
58
|
+
* When active, it may show a submenu.
|
|
59
|
+
*/
|
|
52
60
|
@property({ type: Boolean }) active: boolean = false
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The label to display for the menu item.
|
|
64
|
+
*/
|
|
53
65
|
@property({ type: String }) label!: string
|
|
54
66
|
|
|
55
67
|
@state() _submenu?: OxPopupMenu
|
|
@@ -133,6 +145,12 @@ export class OxPopupMenuItem extends LitElement {
|
|
|
133
145
|
}
|
|
134
146
|
}
|
|
135
147
|
|
|
148
|
+
/**
|
|
149
|
+
* Expands the submenu, if it exists.
|
|
150
|
+
* The submenu is displayed below and to the right of the menu item.
|
|
151
|
+
*
|
|
152
|
+
* @param {boolean} silent - If true, the submenu is opened silently without user interaction.
|
|
153
|
+
*/
|
|
136
154
|
expand(silent: boolean) {
|
|
137
155
|
if (!this._submenu) {
|
|
138
156
|
return
|
|
@@ -143,14 +161,25 @@ export class OxPopupMenuItem extends LitElement {
|
|
|
143
161
|
this._submenu.open({ top, left, silent })
|
|
144
162
|
}
|
|
145
163
|
|
|
164
|
+
/**
|
|
165
|
+
* Collapses the submenu, if it exists.
|
|
166
|
+
*/
|
|
146
167
|
collapse() {
|
|
147
168
|
this._submenu?.close()
|
|
148
169
|
}
|
|
149
170
|
|
|
171
|
+
/**
|
|
172
|
+
* Dispatches a custom 'ox-collapse' event indicating that the menu item should collapse itself.
|
|
173
|
+
* This event can be used to trigger further interactions or logic in the application.
|
|
174
|
+
*/
|
|
150
175
|
collapseSelf() {
|
|
151
176
|
this.dispatchEvent(new CustomEvent('ox-collapse', { bubbles: true, composed: true, detail: this }))
|
|
152
177
|
}
|
|
153
178
|
|
|
179
|
+
/**
|
|
180
|
+
* Dispatches a custom 'ox-close' event indicating that the menu item should close itself.
|
|
181
|
+
* This event can be used to trigger further interactions or logic in the application.
|
|
182
|
+
*/
|
|
154
183
|
close() {
|
|
155
184
|
this.dispatchEvent(new CustomEvent('ox-close', { bubbles: true, composed: true, detail: this }))
|
|
156
185
|
}
|
package/src/ox-popup.ts
CHANGED
|
@@ -4,6 +4,15 @@ import { customElement, state } from 'lit/decorators.js'
|
|
|
4
4
|
|
|
5
5
|
import { ScrollbarStyles } from '@operato/styles'
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Custom element class representing the 'ox-popup' component.
|
|
9
|
+
*
|
|
10
|
+
* This component provides the functionality to display a popup with various configuration options.
|
|
11
|
+
* It can be used to show additional information, notifications, or user interactions within a web application.
|
|
12
|
+
*
|
|
13
|
+
* @fires ox-close - Dispatched when the popup is closed.
|
|
14
|
+
* @fires ox-collapse - Dispatched when the popup is collapsed.
|
|
15
|
+
*/
|
|
7
16
|
@customElement('ox-popup')
|
|
8
17
|
export class OxPopup extends LitElement {
|
|
9
18
|
static styles = [
|
|
@@ -32,12 +41,12 @@ export class OxPopup extends LitElement {
|
|
|
32
41
|
`
|
|
33
42
|
]
|
|
34
43
|
|
|
35
|
-
@state() _parent
|
|
44
|
+
@state() _parent: Element | null = null
|
|
36
45
|
|
|
37
46
|
private lastActive: HTMLElement = document.activeElement as HTMLElement
|
|
38
47
|
|
|
39
48
|
render() {
|
|
40
|
-
return html
|
|
49
|
+
return html`<slot />`
|
|
41
50
|
}
|
|
42
51
|
|
|
43
52
|
protected _onfocusout: (e: FocusEvent) => void = function (this: OxPopup, e: FocusEvent) {
|
|
@@ -122,12 +131,6 @@ export class OxPopup extends LitElement {
|
|
|
122
131
|
* @property {Number} left The position-left where the pop-up will be displayed
|
|
123
132
|
* @property {HTMLElement} parent Popup's parent element
|
|
124
133
|
*/
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Open Popup
|
|
128
|
-
*
|
|
129
|
-
* @param {PopupOpenOptions}
|
|
130
|
-
*/
|
|
131
134
|
static open({
|
|
132
135
|
template,
|
|
133
136
|
top,
|
|
@@ -136,7 +139,8 @@ export class OxPopup extends LitElement {
|
|
|
136
139
|
bottom,
|
|
137
140
|
width,
|
|
138
141
|
height,
|
|
139
|
-
parent
|
|
142
|
+
parent,
|
|
143
|
+
style
|
|
140
144
|
}: {
|
|
141
145
|
template: unknown
|
|
142
146
|
top?: number
|
|
@@ -146,9 +150,13 @@ export class OxPopup extends LitElement {
|
|
|
146
150
|
width?: string
|
|
147
151
|
height?: string
|
|
148
152
|
parent?: Element | null
|
|
153
|
+
style?: string
|
|
149
154
|
}): OxPopup {
|
|
150
155
|
const owner = parent || document.body
|
|
151
156
|
const target = document.createElement('ox-popup') as OxPopup
|
|
157
|
+
if (style) {
|
|
158
|
+
target.style.cssText = style
|
|
159
|
+
}
|
|
152
160
|
|
|
153
161
|
render(template, target)
|
|
154
162
|
|
|
@@ -160,6 +168,18 @@ export class OxPopup extends LitElement {
|
|
|
160
168
|
return target
|
|
161
169
|
}
|
|
162
170
|
|
|
171
|
+
/**
|
|
172
|
+
* Opens the 'ox-popup' with the specified position and dimensions.
|
|
173
|
+
*
|
|
174
|
+
* @param {PopupOpenOptions} options - An object specifying the position and dimensions of the popup.
|
|
175
|
+
* @param {number} options.left - The left position (in pixels) where the popup should be displayed. If not provided, it will be centered horizontally.
|
|
176
|
+
* @param {number} options.top - The top position (in pixels) where the popup should be displayed. If not provided, it will be centered vertically.
|
|
177
|
+
* @param {number} options.right - The right position (in pixels) where the popup should be displayed. If provided, it will override the 'left' value.
|
|
178
|
+
* @param {number} options.bottom - The bottom position (in pixels) where the popup should be displayed. If provided, it will override the 'top' value.
|
|
179
|
+
* @param {string} options.width - The maximum width of the popup (CSS string). For example, '300px'.
|
|
180
|
+
* @param {string} options.height - The maximum height of the popup (CSS string). For example, '200px'.
|
|
181
|
+
* @param {boolean} [options.silent=false] - A flag indicating whether the popup should auto-focus or not. If set to true, the popup won't attempt to focus on any element.
|
|
182
|
+
*/
|
|
163
183
|
open({
|
|
164
184
|
left,
|
|
165
185
|
top,
|
|
@@ -188,9 +208,9 @@ export class OxPopup extends LitElement {
|
|
|
188
208
|
}
|
|
189
209
|
|
|
190
210
|
if (left === undefined && top === undefined && right === undefined && bottom === undefined) {
|
|
211
|
+
this.style.transform = 'translateX(-50%) translateY(-50%)'
|
|
191
212
|
this.style.left = '50%'
|
|
192
213
|
this.style.top = '50%'
|
|
193
|
-
this.style.transform = 'translateX(-50%) translateY(-50%)'
|
|
194
214
|
} else {
|
|
195
215
|
if (left !== undefined) this.style.left = `${left}px`
|
|
196
216
|
if (top !== undefined) this.style.top = `${top}px`
|
|
@@ -229,7 +249,7 @@ export class OxPopup extends LitElement {
|
|
|
229
249
|
const computedStyle = getComputedStyle(this)
|
|
230
250
|
|
|
231
251
|
if (t < 0) {
|
|
232
|
-
this.style.top =
|
|
252
|
+
this.style.top = '0'
|
|
233
253
|
this.style.bottom = ''
|
|
234
254
|
} else if (vh < t + h) {
|
|
235
255
|
this.style.top = `calc(${computedStyle.top} - ${t + h - vh}px)` // 현재의 top 값에 차감한다.
|
|
@@ -237,7 +257,7 @@ export class OxPopup extends LitElement {
|
|
|
237
257
|
}
|
|
238
258
|
|
|
239
259
|
if (l < 0) {
|
|
240
|
-
this.style.left =
|
|
260
|
+
this.style.left = '0'
|
|
241
261
|
this.style.right = ''
|
|
242
262
|
} else if (vw < l + w) {
|
|
243
263
|
this.style.left = `calc(${computedStyle.left} - ${l + w - vw}px)` // 현재의 left 값에 차감한다.
|
|
@@ -264,6 +284,9 @@ export class OxPopup extends LitElement {
|
|
|
264
284
|
}
|
|
265
285
|
}
|
|
266
286
|
|
|
287
|
+
/**
|
|
288
|
+
* Closes the 'ox-popup'.
|
|
289
|
+
*/
|
|
267
290
|
close() {
|
|
268
291
|
this.removeAttribute('active')
|
|
269
292
|
|
|
@@ -282,7 +305,7 @@ export class OxPopup extends LitElement {
|
|
|
282
305
|
this.removeEventListener('contextmenu', this._oncontextmenu)
|
|
283
306
|
|
|
284
307
|
this._parent.removeChild(this)
|
|
285
|
-
|
|
308
|
+
this._parent = null
|
|
286
309
|
|
|
287
310
|
if (this.lastActive) {
|
|
288
311
|
this.lastActive.focus && this.lastActive.focus()
|
package/src/ox-prompt.ts
CHANGED
|
@@ -12,6 +12,9 @@ const TYPES_ICON = {
|
|
|
12
12
|
question: 'question_mark'
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* The `ox-prompt` custom element represents a modal popup that provides information or options for the user, such as confirmation or cancellation.
|
|
17
|
+
*/
|
|
15
18
|
@customElement('ox-prompt')
|
|
16
19
|
export class OxPrompt extends LitElement {
|
|
17
20
|
static styles = [
|
|
@@ -66,14 +69,49 @@ export class OxPrompt extends LitElement {
|
|
|
66
69
|
`
|
|
67
70
|
]
|
|
68
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Specifies the type of the popup. Possible values are 'success', 'error', 'warning', 'info', 'question'.
|
|
74
|
+
*/
|
|
69
75
|
@property({ type: String }) type?: 'success' | 'error' | 'warning' | 'info' | 'question'
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Specifies the icon of the popup.
|
|
79
|
+
*/
|
|
70
80
|
@property({ type: String }) icon?: string
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Specifies the title of the popup.
|
|
84
|
+
*/
|
|
71
85
|
@property({ type: String }) titler?: string = ''
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Specifies the text content of the popup.
|
|
89
|
+
*/
|
|
72
90
|
@property({ type: String }) text?: string
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Specifies the footer (additional information at the bottom) of the popup.
|
|
94
|
+
*/
|
|
73
95
|
@property({ type: String }) footer?: string
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Determines whether the popup is displayed as a toast.
|
|
99
|
+
*/
|
|
74
100
|
@property({ type: Boolean }) toast?: boolean
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Specifies settings for the confirmation button.
|
|
104
|
+
*/
|
|
75
105
|
@property({ type: Object }) confirmButton?: { text: string; color?: string }
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Specifies settings for the cancel button.
|
|
109
|
+
*/
|
|
76
110
|
@property({ type: Object }) cancelButton?: { text: string; color?: string }
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* A callback function called when the popup is closed, providing the result of the user's interaction.
|
|
114
|
+
*/
|
|
77
115
|
@property({ type: Object }) callback?: (result: { value: boolean }) => void
|
|
78
116
|
|
|
79
117
|
@state() _parent?: Element
|
|
@@ -102,11 +140,17 @@ export class OxPrompt extends LitElement {
|
|
|
102
140
|
`
|
|
103
141
|
}
|
|
104
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Function called when the confirm button is clicked.
|
|
145
|
+
*/
|
|
105
146
|
onConfirm() {
|
|
106
147
|
this.resolveFn && this.resolveFn(true)
|
|
107
148
|
this.close()
|
|
108
149
|
}
|
|
109
150
|
|
|
151
|
+
/**
|
|
152
|
+
* Function called when the cancel button is clicked.
|
|
153
|
+
*/
|
|
110
154
|
onCancel() {
|
|
111
155
|
this.resolveFn && this.resolveFn(false)
|
|
112
156
|
this.close()
|
|
@@ -184,6 +228,31 @@ export class OxPrompt extends LitElement {
|
|
|
184
228
|
this.guaranteeFocus()
|
|
185
229
|
}
|
|
186
230
|
|
|
231
|
+
/**
|
|
232
|
+
* Static method to open the `ox-prompt` popup.
|
|
233
|
+
* @param {object} options - An object containing popup options.
|
|
234
|
+
* @param {unknown} [options.template] - An optional content template to render inside the popup.
|
|
235
|
+
* @param {'success' | 'error' | 'warning' | 'info' | 'question'} [options.type] - The type of the popup, which can be one of: 'success', 'error', 'warning', 'info', 'question'.
|
|
236
|
+
* @param {string} [options.icon] - The icon to be displayed in the popup header.
|
|
237
|
+
* @param {string} [options.title] - The title to be displayed in the popup header.
|
|
238
|
+
* @param {string} [options.text] - The main text content of the popup.
|
|
239
|
+
* @param {string} [options.footer] - Additional information to be displayed at the bottom of the popup.
|
|
240
|
+
* @param {object} [options.confirmButton] - Configuration for the confirmation button in the popup.
|
|
241
|
+
* @param {string} options.confirmButton.text - The text to be displayed on the confirmation button.
|
|
242
|
+
* @param {string} [options.confirmButton.color] - The color of the confirmation button (CSS color).
|
|
243
|
+
* @param {object} [options.cancelButton] - Configuration for the cancel button in the popup.
|
|
244
|
+
* @param {string} options.cancelButton.text - The text to be displayed on the cancel button.
|
|
245
|
+
* @param {string} [options.cancelButton.color] - The color of the cancel button (CSS color).
|
|
246
|
+
* @param {number} [options.top] - The top position of the popup (in pixels).
|
|
247
|
+
* @param {number} [options.left] - The left position of the popup (in pixels).
|
|
248
|
+
* @param {number} [options.right] - The right position of the popup (in pixels).
|
|
249
|
+
* @param {number} [options.bottom] - The bottom position of the popup (in pixels).
|
|
250
|
+
* @param {string} [options.width] - The maximum width of the popup (CSS string).
|
|
251
|
+
* @param {string} [options.height] - The maximum height of the popup (CSS string).
|
|
252
|
+
* @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.
|
|
253
|
+
* @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.
|
|
254
|
+
* @returns {Promise<boolean>} A Promise that resolves based on user interaction with the popup.
|
|
255
|
+
*/
|
|
187
256
|
public static async open({
|
|
188
257
|
template,
|
|
189
258
|
type,
|
|
@@ -244,6 +313,18 @@ export class OxPrompt extends LitElement {
|
|
|
244
313
|
return result
|
|
245
314
|
}
|
|
246
315
|
|
|
316
|
+
/**
|
|
317
|
+
* Opens the popup with specified position and dimensions.
|
|
318
|
+
* @param {object} options - An object specifying the position and dimensions of the popup.
|
|
319
|
+
* @param {number} [options.left] - The left position of the popup (in pixels). If not provided, the popup will be horizontally centered.
|
|
320
|
+
* @param {number} [options.top] - The top position of the popup (in pixels). If not provided, the popup will be vertically centered.
|
|
321
|
+
* @param {number} [options.right] - The right position of the popup (in pixels). Overrides 'left' if both 'left' and 'right' are provided.
|
|
322
|
+
* @param {number} [options.bottom] - The bottom position of the popup (in pixels). Overrides 'top' if both 'top' and 'bottom' are provided.
|
|
323
|
+
* @param {string} [options.width] - The maximum width of the popup (CSS string). If not provided, no width restriction is applied.
|
|
324
|
+
* @param {string} [options.height] - The maximum height of the popup (CSS string). If not provided, no height restriction is applied.
|
|
325
|
+
* @param {boolean} [options.silent=false] - Determines whether to focus the popup automatically (true) or not (false).
|
|
326
|
+
* @returns {Promise<boolean>} A Promise that resolves based on user interaction with the popup.
|
|
327
|
+
*/
|
|
247
328
|
open({
|
|
248
329
|
left,
|
|
249
330
|
top,
|
|
@@ -352,6 +433,9 @@ export class OxPrompt extends LitElement {
|
|
|
352
433
|
}
|
|
353
434
|
}
|
|
354
435
|
|
|
436
|
+
/**
|
|
437
|
+
* Closes the popup.
|
|
438
|
+
*/
|
|
355
439
|
close() {
|
|
356
440
|
this.removeAttribute('active')
|
|
357
441
|
|