@imposium-hub/components 1.38.2 → 1.38.4

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.
@@ -18,6 +18,8 @@ interface IListFieldProps {
18
18
  width? : string | number;
19
19
  onChange(e) : void;
20
20
  onError(e) : void;
21
+ onFocus? : () => void;
22
+ onBlur? : () => void;
21
23
  info? : string;
22
24
  labelPosition? : string;
23
25
  }
@@ -61,6 +63,9 @@ class ListField extends React.PureComponent<IListFieldProps, IListFieldState> {
61
63
  private inputBlur(e) {
62
64
 
63
65
  hotkeys.unbind('enter', this.submitHandler);
66
+ if (this.props.onBlur) {
67
+ this.props.onBlur();
68
+ }
64
69
  }
65
70
 
66
71
  private inputChanged(e) {
@@ -72,10 +77,9 @@ class ListField extends React.PureComponent<IListFieldProps, IListFieldState> {
72
77
 
73
78
  private inputFocus(e) {
74
79
 
75
- const input = this.inputRef.current;
76
-
77
- if (input) {
78
- hotkeys('enter', this.submitHandler);
80
+ hotkeys('enter', this.submitHandler);
81
+ if (this.props.onFocus) {
82
+ this.props.onFocus();
79
83
  }
80
84
  }
81
85
 
@@ -162,7 +166,7 @@ class ListField extends React.PureComponent<IListFieldProps, IListFieldState> {
162
166
  style = 'subtle'
163
167
  tooltip = {tooltipAdd}
164
168
  color = 'primary'
165
- onClick = {() => this.submitOption()}>
169
+ onClick = {this.submitHandler}>
166
170
  {ICON_PLUS}
167
171
  </Button>);
168
172
 
@@ -1,7 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import FieldWrapper from '../field-wrapper/FieldWrapper';
3
3
  import { IToolTipConfig } from '../Tooltip';
4
- import { ICON_CARET_DOWN } from '../../constants/icons';
4
+ import {ICON_CARET_DOWN, ICON_CLIPBOARD} from '../../constants/icons';
5
+ import Button from '../button/Button';
5
6
 
6
7
  interface ISelectOption {
7
8
  label : string;
@@ -22,15 +23,33 @@ interface ISelectFieldProps {
22
23
  onChange(e) : void;
23
24
  info? : string;
24
25
  labelPosition? : string;
26
+ showCopy? : boolean;
27
+ onNotification?(e) : void;
28
+ onError?(e) : void;
25
29
  }
26
30
 
27
31
  class SelectField extends React.PureComponent<ISelectFieldProps, {}> {
28
-
32
+ private evtHandlers = {
33
+ copyToClipboard: (e) => this.copyToClipboard(e),
34
+ };
29
35
  constructor(props) {
30
36
 
31
37
  super(props);
32
38
  }
39
+ private copyToClipboard(e) {
40
+
41
+ const {onNotification, onError} = this.props;
42
+ navigator.clipboard.writeText(this.props.value).then(() => {
33
43
 
44
+ if (onNotification) {
45
+ onNotification('Copied to clipboard!');
46
+ }
47
+ }, () => {
48
+ if (onError) {
49
+ onError('Error copying to clipboard.');
50
+ }
51
+ });
52
+ }
34
53
  private onChange(e) {
35
54
 
36
55
  // handle selects converting booleans to strings
@@ -43,7 +62,7 @@ class SelectField extends React.PureComponent<ISelectFieldProps, {}> {
43
62
 
44
63
  public render() {
45
64
 
46
- const {label, placeholder, options, value, width, buttons, selectRef, disable, tooltip, info, labelPosition, disableFirst} = this.props;
65
+ const {label, showCopy, placeholder, options, value, width, buttons, selectRef, disable, tooltip, info, labelPosition, disableFirst} = this.props;
47
66
  let opts = [];
48
67
 
49
68
  const selectValue = (value === null || value === undefined) ? '' : value;
@@ -59,6 +78,16 @@ class SelectField extends React.PureComponent<ISelectFieldProps, {}> {
59
78
  } else {
60
79
  btns = [caret];
61
80
  }
81
+ if (showCopy) {
82
+ btns.push(<Button
83
+ key = 'btn-copy'
84
+ style = 'subtle'
85
+ color = 'primary'
86
+ tooltip = 'Copy to Clipboard'
87
+ onClick = {this.evtHandlers.copyToClipboard}>
88
+ {ICON_CLIPBOARD}
89
+ </Button>);
90
+ }
62
91
 
63
92
  if (options) {
64
93
  opts = options.map((option , i) => {