goblin-gadgets 2.0.13 → 2.0.16

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-gadgets",
3
- "version": "2.0.13",
3
+ "version": "2.0.16",
4
4
  "description": "Gadgets library",
5
5
  "main": "./builders/builders.js",
6
6
  "scripts": {
@@ -93,6 +93,13 @@ class HinterFieldControl extends Widget {
93
93
  }
94
94
 
95
95
  clear() {
96
+ const service = this.workitemId.split('@', 1)[0];
97
+ const action = `clear-${this.props.hinter}`;
98
+ if (this.canDo(`${service}.${action}`)) {
99
+ this.doFor(this.workitemId, action, {
100
+ previousValue: this.props.selectedId,
101
+ });
102
+ }
96
103
  this.props.onChange(null);
97
104
  }
98
105
 
@@ -12,17 +12,14 @@ export default function styles(theme, props) {
12
12
  top: '0px',
13
13
  bottom: '0px',
14
14
  display: 'flex',
15
- flexDirection: 'row',
15
+ flexDirection: 'column',
16
16
  background: background,
17
17
  overflow: 'hidden',
18
18
  transition: '0.5s ease-in-out',
19
19
  };
20
20
 
21
21
  const title = {
22
- position: 'absolute',
23
- left: '0px',
24
- right: '0px',
25
- top: '5%',
22
+ margin: '20px 0px 0px 0px ',
26
23
  display: 'flex',
27
24
  flexDirection: 'row',
28
25
  textTransform: 'uppercase',
@@ -30,12 +27,13 @@ export default function styles(theme, props) {
30
27
  };
31
28
 
32
29
  const rockets = {
30
+ flexGrow: 1,
31
+ padding: '10px 10px 0px 10px',
33
32
  display: 'flex',
34
33
  flexDirection: 'row',
35
34
  justifyContent: 'center',
36
- alignSelf: 'center',
37
- margin: 'auto',
38
- paddingTop: '5%',
35
+ flexWrap: 'wrap',
36
+ overflowY: 'auto',
39
37
  };
40
38
 
41
39
  return {
@@ -36,7 +36,7 @@ export default class Launcher extends Widget {
36
36
  return (
37
37
  <Rocket
38
38
  key={index}
39
- size={this.props.rocketSize || '200px'}
39
+ size="200px"
40
40
  textColor={this.props.rocketTextColor || '#fff'}
41
41
  shadow={this.props.rocketShadow || 'none'}
42
42
  iconShadow={this.props.rocketIconShadow || 'none'}
@@ -36,6 +36,7 @@ export default function styles(theme, props) {
36
36
  transformOrigin: '50% 50%',
37
37
  animation: `${duration} ease-in-out infinite ${direction}`,
38
38
  animationName: keyframesBlob,
39
+ pointerEvents: 'none',
39
40
  };
40
41
 
41
42
  const launcherWave = {
@@ -49,6 +50,7 @@ export default function styles(theme, props) {
49
50
  animation: `${duration} ease-in-out infinite ${direction}`,
50
51
  animationDirection: 'alternate',
51
52
  animationName: keyframesWave,
53
+ pointerEvents: 'none',
52
54
  };
53
55
 
54
56
  return {
@@ -40,7 +40,7 @@ export default function styles(theme, props) {
40
40
  const rr1 = px(s / 20);
41
41
  const rr2 = px(s / 5);
42
42
  const m = px(s / 20);
43
- const hm = px(s / 5);
43
+ const mb = px(s / 1.8);
44
44
 
45
45
  const rs1 = {
46
46
  none: px(0),
@@ -78,17 +78,14 @@ export default function styles(theme, props) {
78
78
  'flexDirection': 'column',
79
79
  'justifyContent': 'center',
80
80
  'alignSelf': 'center',
81
- 'margin': `0px ${m}`,
81
+ 'margin': `0px ${m} ${mb} ${m}`,
82
82
  'transformOrigin': 'bottom',
83
83
  'transition': disabled
84
84
  ? null
85
85
  : 'background 0.5s ease-in-out, margin 0.5s ease-in-out, transform 0.5s ease-in-out, opacity 0.5s ease-in-out',
86
- ':hover': {
87
- margin: hover ? `0px ${hm}` : null,
88
- transform: hover ? 'scale(1.3)' : null,
89
- },
90
86
  ':hover .box-hover': {
91
87
  background: hover ? backgroundHover : null,
88
+ transform: hover ? 'scale(1.05)' : null,
92
89
  },
93
90
  ':hover .gear-hover': {
94
91
  transition: 'cubic-bezier(0.37, 3.43, 0.55, 1) 0.4s',
@@ -106,6 +103,8 @@ export default function styles(theme, props) {
106
103
  borderRadius: kind === 'toy' ? rr2 : rr1,
107
104
  boxShadow: shadow ? `0px ${rs1} ${rs2} ${rs3} rgba(0,0,0,${rs4})` : null,
108
105
  background: background,
106
+ cursor: disabled ? null : 'pointer',
107
+ transition: disabled ? null : 'transform 0.2s ease-in-out',
109
108
  };
110
109
 
111
110
  const icon = {
@@ -118,8 +117,13 @@ export default function styles(theme, props) {
118
117
  };
119
118
 
120
119
  const glyph = {
121
- ...icon,
120
+ position: 'absolute',
121
+ top: px(s * 0.15),
122
+ left: '0px',
123
+ right: '0px',
124
+ height: px(s * 0.5),
122
125
  display: 'flex',
126
+ opacity: disabled ? 0.4 : 1,
123
127
  };
124
128
 
125
129
  const iconSvg = {
@@ -192,7 +196,7 @@ export default function styles(theme, props) {
192
196
  transform: 'scale(0.5)',
193
197
  };
194
198
 
195
- let transition, animation, animationName;
199
+ let transition, additionnalAnimation, additionnalAnimationName;
196
200
  if (additionalAnimation === 'parkinson') {
197
201
  const keyframes = {
198
202
  '0%': {transform: 'translate(0%, 0%) rotate(0deg)'},
@@ -217,8 +221,8 @@ export default function styles(theme, props) {
217
221
  '95%': {transform: 'translate(1%, 0.2%) rotate(0.5deg)'},
218
222
  '100%': {transform: 'translate(-0.5%, -0.6%) rotate(0deg)'},
219
223
  };
220
- animation = '1s ease-in-out infinite reverse';
221
- animationName = keyframes;
224
+ additionnalAnimation = '1s ease-in-out infinite reverse';
225
+ additionnalAnimationName = keyframes;
222
226
  } else if (additionalAnimation === 'zoom') {
223
227
  const keyframes = {
224
228
  '0%': {transform: 'scale(1)'},
@@ -226,8 +230,8 @@ export default function styles(theme, props) {
226
230
  '100%': {transform: 'scale(1)'},
227
231
  };
228
232
  transition = '0.1 ease-out';
229
- animation = '0.6s ease-in-out infinite';
230
- animationName = keyframes;
233
+ additionnalAnimation = '0.6s ease-in-out infinite';
234
+ additionnalAnimationName = keyframes;
231
235
  } else if (additionalAnimation === 'shift') {
232
236
  const keyframes = {
233
237
  '0%': {transform: 'translateX(0%)'},
@@ -237,8 +241,8 @@ export default function styles(theme, props) {
237
241
  '100%': {transform: 'translateX(0%)'},
238
242
  };
239
243
  transition = '0.1 ease-out';
240
- animation = '0.4s ease-in-out infinite';
241
- animationName = keyframes;
244
+ additionnalAnimation = '0.4s ease-in-out infinite';
245
+ additionnalAnimationName = keyframes;
242
246
  } else if (additionalAnimation === 'dancing') {
243
247
  const keyframes = {
244
248
  '0%': {transform: 'rotate(4deg) translate(0%, 0%)'},
@@ -254,8 +258,8 @@ export default function styles(theme, props) {
254
258
  '100%': {transform: 'rotate(4deg) translate(0%, 0%)'},
255
259
  };
256
260
  transition = '0.3 ease-out';
257
- animation = '1.2s ease-in-out infinite reverse';
258
- animationName = keyframes;
261
+ additionnalAnimation = '1.2s ease-in-out infinite reverse';
262
+ additionnalAnimationName = keyframes;
259
263
  }
260
264
 
261
265
  const additional = {
@@ -272,10 +276,11 @@ export default function styles(theme, props) {
272
276
  'flexDirection': 'row',
273
277
  'justifyContent': 'center',
274
278
  'alignSelf': 'center',
279
+ 'cursor': disabled ? null : 'pointer',
275
280
  'transition': transition,
276
281
  ':hover': {
277
- animation,
278
- animationName,
282
+ animation: additionnalAnimation,
283
+ animationName: additionnalAnimationName,
279
284
  },
280
285
  };
281
286
 
@@ -50,6 +50,7 @@ export default class Rocket extends Widget {
50
50
  glyphSize={glyphSize}
51
51
  justify="center"
52
52
  glyphPosition="center"
53
+ cursor="inherit"
53
54
  />
54
55
  </div>
55
56
  );
@@ -119,6 +120,7 @@ export default class Rocket extends Widget {
119
120
  grow="1"
120
121
  fontSize={fontSize}
121
122
  justify="center"
123
+ cursor="inherit"
122
124
  />
123
125
  </div>
124
126
  </>
@@ -159,6 +161,7 @@ export default class Rocket extends Widget {
159
161
  glyphSize={glyphSize}
160
162
  justify="center"
161
163
  glyphPosition="center"
164
+ cursor="inherit"
162
165
  />
163
166
  </div>
164
167
  );
@@ -174,6 +177,7 @@ export default class Rocket extends Widget {
174
177
  fontSize={fontSize}
175
178
  justify="center"
176
179
  wrap="no"
180
+ cursor="inherit"
177
181
  />
178
182
  </div>
179
183
  );
@@ -189,15 +193,12 @@ export default class Rocket extends Widget {
189
193
  fontSize={fontSize}
190
194
  justify="center"
191
195
  wrap="no"
196
+ cursor="inherit"
192
197
  />
193
198
  </div>
194
199
  );
195
200
  }
196
201
 
197
- renderBox() {
198
- return <div className={`box-hover ${this.styles.classNames.box}`} />;
199
- }
200
-
201
202
  render() {
202
203
  return (
203
204
  <div
@@ -205,11 +206,12 @@ export default class Rocket extends Widget {
205
206
  onClick={this.props.onClick}
206
207
  >
207
208
  {this.renderAdditional()}
208
- {this.renderBox()}
209
209
  {this.renderIcon()}
210
- {this.renderGlyph()}
211
- {this.renderTitle()}
212
- {this.renderSubtitle()}
210
+ <div className={`box-hover ${this.styles.classNames.box}`}>
211
+ {this.renderGlyph()}
212
+ {this.renderTitle()}
213
+ {this.renderSubtitle()}
214
+ </div>
213
215
  {this.renderGauge()}
214
216
  {this.renderOverflow()}
215
217
  {this.renderCrossed()}
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import Widget from 'goblin-laboratory/widgets/widget';
3
+ import Form from 'goblin-laboratory/widgets/form';
3
4
  import * as styles from './styles';
4
5
  import Tree from 'goblin-gadgets/widgets/tree/widget';
5
6
  import Label from 'goblin-gadgets/widgets/label/widget';
@@ -8,6 +9,23 @@ import T from 't';
8
9
 
9
10
  /******************************************************************************/
10
11
 
12
+ function onCopyToClipboard(text) {
13
+ Form.copyTextToClipboard(text);
14
+ }
15
+
16
+ function renderCopyButton(text) {
17
+ return (
18
+ <Button
19
+ glyph="solid/copy"
20
+ tooltip={T('Copy to clipboard')}
21
+ width="32px"
22
+ height="32px"
23
+ border="none"
24
+ onClick={() => onCopyToClipboard(text)}
25
+ />
26
+ );
27
+ }
28
+
11
29
  function getRows(state, parentKey) {
12
30
  const rows = [];
13
31
 
@@ -26,7 +44,9 @@ function getRows(state, parentKey) {
26
44
  } else if (typeof value === 'object') {
27
45
  row.rows = getRows(value, id);
28
46
  } else {
29
- row.value = value.toString();
47
+ const text = value.toString();
48
+ row.value = text;
49
+ row.copy = () => renderCopyButton(text);
30
50
  }
31
51
 
32
52
  rows.push(row);
@@ -137,6 +157,10 @@ class StateMonitor extends Widget {
137
157
  textAlign: 'left',
138
158
  indent: 'space',
139
159
  },
160
+ {
161
+ name: 'copy',
162
+ width: '32px',
163
+ },
140
164
  ],
141
165
  rows: [],
142
166
  };
@@ -14,6 +14,7 @@ export default class TreeCell extends Widget {
14
14
  this.styles = styles;
15
15
 
16
16
  this.onMouseDown = this.onMouseDown.bind(this);
17
+ this.onClick = this.onClick.bind(this);
17
18
  this.onDoubleClick = this.onDoubleClick.bind(this);
18
19
  }
19
20
 
@@ -24,6 +25,13 @@ export default class TreeCell extends Widget {
24
25
  }
25
26
  }
26
27
 
28
+ onClick() {
29
+ const x = this.props.onClick;
30
+ if (x) {
31
+ x(this.props.rowId);
32
+ }
33
+ }
34
+
27
35
  onDoubleClick() {
28
36
  const x = this.props.onDoubleClick;
29
37
  if (x) {
@@ -31,7 +39,7 @@ export default class TreeCell extends Widget {
31
39
  }
32
40
  }
33
41
 
34
- render() {
42
+ renderLabel() {
35
43
  let glyph = null;
36
44
  let glyphColor = null;
37
45
  let text = null;
@@ -66,6 +74,27 @@ export default class TreeCell extends Widget {
66
74
  </div>
67
75
  );
68
76
  }
77
+
78
+ // Table accept a function in text, to render a specific component.
79
+ renderFunction() {
80
+ return (
81
+ <div
82
+ key={this.props.index}
83
+ className={this.styles.classNames.cell}
84
+ onClick={this.onClick}
85
+ >
86
+ {this.props.text()}
87
+ </div>
88
+ );
89
+ }
90
+
91
+ render() {
92
+ if (typeof this.props.text === 'function') {
93
+ return this.renderFunction();
94
+ } else {
95
+ return this.renderLabel();
96
+ }
97
+ }
69
98
  }
70
99
 
71
100
  /******************************************************************************/