goblin-magic 1.9.5 → 1.10.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "goblin-magic",
3
- "version": "1.9.5",
3
+ "version": "1.10.0",
4
4
  "description": "goblin-magic",
5
5
  "author": "Epsitec SA",
6
6
  "contributors": [
@@ -13,16 +13,9 @@ export default function styles() {
13
13
  margin: 0,
14
14
  };
15
15
 
16
- const buttons = {
17
- display: 'flex',
18
- flexDirection: 'row',
19
- padding: '1px',
20
- };
21
-
22
16
  return {
23
17
  items,
24
18
  item,
25
19
  hr,
26
- buttons,
27
20
  };
28
21
  }
@@ -81,7 +81,7 @@ class CheckboxMenuItemsNC extends Widget {
81
81
  }
82
82
 
83
83
  render() {
84
- const {values, checkedValues, renderValue, children} = this.props;
84
+ const {values, checkedValues, renderValue, hr, children} = this.props;
85
85
  this.values = values ? [...values] : [];
86
86
  const renderedChildren = React.Children.map(children, (child) => {
87
87
  if (React.isValidElement(child) && child.type === 'option') {
@@ -97,8 +97,8 @@ class CheckboxMenuItemsNC extends Widget {
97
97
  {values?.map((value) => this.renderItem(value, renderValue(value)))}
98
98
  {renderedChildren}
99
99
  </div>
100
- <Menu.Hr className={this.styles.classNames.hr} />
101
- <div className={this.styles.classNames.buttons}>
100
+ {hr !== false && <Menu.Hr className={this.styles.classNames.hr} />}
101
+ <Menu.Row>
102
102
  <MagicButton simple onPointerUp={this.all}>
103
103
  <Icon path={mdiCheckboxMarked} size="1.2em" />
104
104
  Tout
@@ -111,12 +111,14 @@ class CheckboxMenuItemsNC extends Widget {
111
111
  <Icon path={mdiCheckboxIntermediateVariant} size="1.2em" />
112
112
  Inverser
113
113
  </MagicButton>
114
- </div>
114
+ </Menu.Row>
115
115
  </>
116
116
  );
117
117
  }
118
118
  }
119
119
 
120
- const CheckboxMenuItems = withC(CheckboxMenuItemsNC);
120
+ const CheckboxMenuItems = withC(CheckboxMenuItemsNC, {
121
+ checkedValues: 'onChange',
122
+ });
121
123
 
122
124
  export default CheckboxMenuItems;
@@ -0,0 +1,19 @@
1
+ export default function styles() {
2
+ const inlineIcon = {
3
+ display: 'inline-block',
4
+ };
5
+
6
+ const icon = {
7
+ verticalAlign: 'middle',
8
+ position: 'relative',
9
+ top: '-1.6px',
10
+ boxSizing: 'content-box',
11
+ margin: '-15% 0',
12
+ paddingTop: '4%',
13
+ };
14
+
15
+ return {
16
+ inlineIcon,
17
+ icon,
18
+ };
19
+ }
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import Widget from 'goblin-laboratory/widgets/widget';
3
+ import * as styles from './styles.js';
4
+ import Icon from '@mdi/react';
5
+
6
+ class InlineIcon extends Widget {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.styles = styles;
10
+ }
11
+
12
+ render() {
13
+ const {className = '', ...props} = this.props;
14
+ return (
15
+ <span className={this.styles.classNames.inlineIcon + ' ' + className}>
16
+ <Icon {...props} className={this.styles.classNames.icon} />
17
+ </span>
18
+ );
19
+ }
20
+ }
21
+
22
+ export default InlineIcon;
@@ -11,7 +11,7 @@ export default function styles() {
11
11
  'border':
12
12
  '1px solid color-mix(in srgb, var(--text-color), transparent 50%)',
13
13
  'borderRadius': '5px',
14
- 'padding': '6px 8px',
14
+ 'padding': '4px 8px',
15
15
  'color': 'inherit',
16
16
  'display': 'inline-flex',
17
17
  'flexDirection': 'row',
@@ -1334,7 +1334,7 @@ class MagicNavigation extends Elf {
1334
1334
  * @param {id} windowId
1335
1335
  * @param {id} dialogId
1336
1336
  */
1337
- _removeDialog(windowId, dialogId) {
1337
+ async _removeDialog(windowId, dialogId) {
1338
1338
  this.logic._removeDialog(windowId, dialogId);
1339
1339
  }
1340
1340
 
@@ -8,7 +8,8 @@ export default function styles() {
8
8
  'flexDirection': 'row',
9
9
  'alignItems': 'center',
10
10
  'textAlign': 'left',
11
- 'padding': '6px 8px',
11
+ 'padding': '4px 8px',
12
+ 'minHeight': '31px',
12
13
  'color': 'var(--text-color)',
13
14
  'fontSize': '14px',
14
15
  'outline': '1px solid transparent',
@@ -33,6 +34,13 @@ export default function styles() {
33
34
  marginRight: '6px',
34
35
  minWidth: '18px',
35
36
  },
37
+
38
+ '&[data-enabled=true]:not(:hover)': {
39
+ backgroundColor: 'rgba(255,177,60,0.4)',
40
+ border: '1px solid rgba(255,153,0,0.5)',
41
+ boxShadow: '0px 0px 3px rgba(255,153,0,0.7)',
42
+ padding: '3px 7px',
43
+ },
36
44
  };
37
45
 
38
46
  const menuItemRight = {
@@ -156,6 +164,12 @@ export default function styles() {
156
164
  alignSelf: 'center',
157
165
  };
158
166
 
167
+ const menuRow = {
168
+ display: 'flex',
169
+ flexDirection: 'row',
170
+ padding: '1px',
171
+ };
172
+
159
173
  return {
160
174
  submenu,
161
175
  menuItem,
@@ -166,6 +180,7 @@ export default function styles() {
166
180
  menuPosition,
167
181
  menuContent,
168
182
  menuHr,
183
+ menuRow,
169
184
  };
170
185
  }
171
186
 
@@ -6,6 +6,7 @@ import {faBars, faChevronRight} from '@fortawesome/free-solid-svg-icons';
6
6
  import MagicButton from 'goblin-magic/widgets/magic-button/widget.js';
7
7
  import WithComputedSize from '../with-computed-size/widget.js';
8
8
  import MenuDialog from '../menu-dialog/widget.js';
9
+ import withC from 'goblin-laboratory/widgets/connect-helpers/with-c.js';
9
10
 
10
11
  const MenuContext = React.createContext();
11
12
  const MenuStateContext = React.createContext();
@@ -55,7 +56,7 @@ class MenuItem extends Widget {
55
56
  }
56
57
 
57
58
  render() {
58
- const {className = '', rightIcon, children, ...props} = this.props;
59
+ const {className = '', rightIcon, enabled, children, ...props} = this.props;
59
60
  return (
60
61
  <MenuContext.Consumer>
61
62
  {(menu) => (
@@ -64,11 +65,14 @@ class MenuItem extends Widget {
64
65
  className={this.styles.classNames.menuItem + ' ' + className}
65
66
  onPointerUp={(event) => this.handlePointerUp(event, menu)}
66
67
  onClick={(event) => this.handleClick(event, menu)}
68
+ data-enabled={enabled}
67
69
  >
68
70
  {children}
69
- <div className={this.styles.classNames.menuItemRight}>
70
- {rightIcon}
71
- </div>
71
+ {rightIcon !== null && (
72
+ <div className={this.styles.classNames.menuItemRight}>
73
+ {rightIcon}
74
+ </div>
75
+ )}
72
76
  </button>
73
77
  )}
74
78
  </MenuContext.Consumer>
@@ -186,6 +190,25 @@ class MenuHr extends Widget {
186
190
  }
187
191
  }
188
192
 
193
+ class MenuRow extends Widget {
194
+ constructor() {
195
+ super(...arguments);
196
+ this.styles = styles;
197
+ }
198
+
199
+ render() {
200
+ const {className = '', children, ...props} = this.props;
201
+ return (
202
+ <div
203
+ {...props}
204
+ className={this.styles.classNames.menuRow + ' ' + className}
205
+ >
206
+ {children}
207
+ </div>
208
+ );
209
+ }
210
+ }
211
+
189
212
  class MenuButton extends Widget {
190
213
  constructor() {
191
214
  super(...arguments);
@@ -651,10 +674,11 @@ export default class Menu extends Widget {
651
674
 
652
675
  static Context = MenuContext;
653
676
  static Content = MenuContent;
654
- static Item = MenuItem;
677
+ static Item = withC(MenuItem);
655
678
  static Title = MenuTitle;
656
679
  static Div = MenuDiv;
657
680
  static Submenu = Submenu;
658
681
  static Hr = MenuHr;
682
+ static Row = MenuRow;
659
683
  static Button = MenuButton;
660
684
  }