goblin-magic 1.0.13 → 1.3.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.
package/package.json
CHANGED
|
@@ -613,13 +613,18 @@ class MagicNavigation extends Elf {
|
|
|
613
613
|
/**
|
|
614
614
|
* @param {id} parentId
|
|
615
615
|
* @param {string} prompt
|
|
616
|
-
* @param {
|
|
617
|
-
* @param {string} [
|
|
618
|
-
* @param {string} [
|
|
619
|
-
* @param {string} [
|
|
620
|
-
* @
|
|
616
|
+
* @param {object} [options]
|
|
617
|
+
* @param {string} [options.advice]
|
|
618
|
+
* @param {string} [options.okLabel]
|
|
619
|
+
* @param {string} [options.cancelLabel]
|
|
620
|
+
* @param {string} [options.initialValue]
|
|
621
|
+
* @returns {Promise<string>}
|
|
621
622
|
*/
|
|
622
|
-
async prompt(
|
|
623
|
+
async prompt(
|
|
624
|
+
parentId,
|
|
625
|
+
prompt,
|
|
626
|
+
{advice, okLabel, cancelLabel, initialValue} = {}
|
|
627
|
+
) {
|
|
623
628
|
const dialogId = await this.openDialog(
|
|
624
629
|
{
|
|
625
630
|
widget: 'PromptDialog',
|
package/widgets/menu/styles.js
CHANGED
|
@@ -65,6 +65,10 @@ export default function styles() {
|
|
|
65
65
|
},
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
+
const menuDiv = {
|
|
69
|
+
padding: '6px 8px',
|
|
70
|
+
};
|
|
71
|
+
|
|
68
72
|
const menuDialog = {
|
|
69
73
|
'::backdrop': {
|
|
70
74
|
backgroundColor: 'transparent',
|
|
@@ -146,6 +150,7 @@ export default function styles() {
|
|
|
146
150
|
menuItem,
|
|
147
151
|
menuItemRight,
|
|
148
152
|
menuTitle,
|
|
153
|
+
menuDiv,
|
|
149
154
|
menuDialog,
|
|
150
155
|
menuPosition,
|
|
151
156
|
menuContent,
|
package/widgets/menu/widget.js
CHANGED
|
@@ -96,6 +96,25 @@ class MenuTitle extends Widget {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
class MenuDiv extends Widget {
|
|
100
|
+
constructor() {
|
|
101
|
+
super(...arguments);
|
|
102
|
+
this.styles = styles;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
render() {
|
|
106
|
+
const {className = '', children, ...props} = this.props;
|
|
107
|
+
return (
|
|
108
|
+
<div
|
|
109
|
+
{...props}
|
|
110
|
+
className={this.styles.classNames.menuDiv + ' ' + className}
|
|
111
|
+
>
|
|
112
|
+
{children}
|
|
113
|
+
</div>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
99
118
|
class Submenu extends Widget {
|
|
100
119
|
constructor() {
|
|
101
120
|
super(...arguments);
|
|
@@ -299,7 +318,19 @@ class MenuContent extends Widget {
|
|
|
299
318
|
const firstTop = firstPos === 'top';
|
|
300
319
|
|
|
301
320
|
if (size.height > window.innerHeight) {
|
|
302
|
-
|
|
321
|
+
if (state.fromContextMenu) {
|
|
322
|
+
return 'full';
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// Prevent overlap on the button
|
|
326
|
+
const spaceAbove = top;
|
|
327
|
+
const spaceBelow = window.innerHeight - bottom;
|
|
328
|
+
|
|
329
|
+
if (firstBottom || (!firstTop && spaceBelow >= spaceAbove)) {
|
|
330
|
+
return 'bottom-constrained'; // Open to the bottom
|
|
331
|
+
} else {
|
|
332
|
+
return 'top-constrained'; // Open to the top
|
|
333
|
+
}
|
|
303
334
|
}
|
|
304
335
|
|
|
305
336
|
if (firstBottom || firstTop) {
|
|
@@ -349,6 +380,8 @@ class MenuContent extends Widget {
|
|
|
349
380
|
'start': {top: 0},
|
|
350
381
|
'end': {bottom: 0},
|
|
351
382
|
'full': {top: 0, bottom: 0},
|
|
383
|
+
'bottom-constrained': {top: bottom, bottom: '8px'},
|
|
384
|
+
'top-constrained': {top: '8px', bottom: `calc(100% - ${top}px)`},
|
|
352
385
|
}[verticalPos];
|
|
353
386
|
|
|
354
387
|
const horizontalPos = (() => {
|
|
@@ -518,6 +551,7 @@ export default class Menu extends Widget {
|
|
|
518
551
|
}
|
|
519
552
|
|
|
520
553
|
close() {
|
|
554
|
+
this.props.onClose?.();
|
|
521
555
|
this.setState({open: false});
|
|
522
556
|
}
|
|
523
557
|
|
|
@@ -569,6 +603,7 @@ export default class Menu extends Widget {
|
|
|
569
603
|
static Content = MenuContent;
|
|
570
604
|
static Item = MenuItem;
|
|
571
605
|
static Title = MenuTitle;
|
|
606
|
+
static Div = MenuDiv;
|
|
572
607
|
static Submenu = Submenu;
|
|
573
608
|
static Hr = MenuHr;
|
|
574
609
|
static Button = MenuButton;
|