@dvrd/dvr-controls 0.0.31 → 0.0.36

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": "@dvrd/dvr-controls",
3
- "version": "0.0.31",
3
+ "version": "0.0.36",
4
4
  "description": "Custom web controls",
5
5
  "main": "index.ts",
6
6
  "scripts": {},
@@ -67,7 +67,7 @@ export default function DvrdButton(props: DvrdButtonProps) {
67
67
  else if (customBaseColor) color = customBaseColor;
68
68
  else if (red) {
69
69
  if (secondary) color = 'color-red-secondary';
70
- else color = 'red';
70
+ else color = 'rgb(255,0,0)';
71
71
  } else if (secondary) color = context.contrastColor;
72
72
  else color = context.baseColor;
73
73
  color = convertColor(color);
@@ -84,6 +84,7 @@
84
84
  opacity: 0;
85
85
  transition: color .2s ease-in-out, opacity .2s ease-in-out, visibility .2s ease-in-out;
86
86
  padding: .25rem;
87
+ user-select: none;
87
88
 
88
89
  &:hover {
89
90
  color: $color-gray-7;
@@ -34,6 +34,7 @@ interface Props {
34
34
  interface State {
35
35
  settings: PDFTextParams;
36
36
  dragging: boolean;
37
+ focused: boolean;
37
38
  }
38
39
 
39
40
  export default class PdfText extends PdfElement<Props, State> {
@@ -61,6 +62,7 @@ export default class PdfText extends PdfElement<Props, State> {
61
62
  persistent: PDFElementPersist.NOT_PERSISTENT,
62
63
  }, props.defaultSettings),
63
64
  dragging: false,
65
+ focused: false,
64
66
  }
65
67
  this.currentText = this.state.settings.text;
66
68
  this.events = [this.event, {eventName: 'onLinkedElementMoved', handler: this.onLinkedElementMoved}]
@@ -68,14 +70,22 @@ export default class PdfText extends PdfElement<Props, State> {
68
70
 
69
71
  private onBlur = (evt: React.FocusEvent<HTMLTextAreaElement>) => {
70
72
  this.lastKnownCursor = evt.target.selectionEnd || 0;
73
+ this.setState({focused: false}, this.setWidth);
71
74
  if (this.state.settings.text !== this.currentText) this.props.onSaveHistory();
72
75
  };
73
76
 
74
77
  private onFocus = (evt: React.FocusEvent) => {
75
78
  evt.stopPropagation();
79
+ this.setState({focused: true}, this.setWidth);
76
80
  this.currentText = this.state.settings.text;
77
81
  };
78
82
 
83
+ getTextValue = (): string => {
84
+ const {settings, focused} = this.state, {values} = this.props;
85
+ if (focused) return settings.text;
86
+ return setPdfVariables(settings.text, values);
87
+ }
88
+
79
89
  public setSetting = (key: string, value: any, callback?: VoidFunction, save: boolean = true) => {
80
90
  this.setState({settings: Object.assign({}, this.state.settings, {[key]: value})}, () => {
81
91
  this.setWidth();
@@ -215,7 +225,6 @@ export default class PdfText extends PdfElement<Props, State> {
215
225
  render = () => {
216
226
  const {settings, dragging} = this.state, {
217
227
  draggable,
218
- values,
219
228
  defaultPosition,
220
229
  onSaveHistory,
221
230
  persistent
@@ -234,7 +243,7 @@ export default class PdfText extends PdfElement<Props, State> {
234
243
  <div className='pdf-text-container'>
235
244
  <textarea className='pdf-text-input' style={this.getTextStyle()}
236
245
  readOnly={settings.disabled === true}
237
- value={sanitizeHtml(setPdfVariables(settings.text, values))} onChange={this.onChange}
246
+ value={sanitizeHtml(this.getTextValue())} onChange={this.onChange}
238
247
  rows={this.getRows()} onFocus={this.onFocus} onBlur={this.onBlur} onClick={this.onClick}
239
248
  ref={(ref: HTMLTextAreaElement) => {
240
249
  this.field = ref
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import './style/dvrdSelect.scss';
5
5
 
6
- import React, {MouseEventHandler, PureComponent} from 'react';
6
+ import React, {CSSProperties, MouseEventHandler, PureComponent} from 'react';
7
7
  import classNames from 'classnames';
8
8
  import {ChangeFunction, ErrorType, SelectItemShape} from '../util/interfaces';
9
9
  import {hasHover, stopPropagation } from '../util/controlUtil';
@@ -27,6 +27,7 @@ interface Props {
27
27
  itemsPosition: 'top' | 'bottom';
28
28
  selectOnly: boolean;
29
29
  searchValue: string;
30
+ optionsContainerHeight: number | string;
30
31
  }
31
32
 
32
33
  interface State {
@@ -84,6 +85,12 @@ export default class DvrdSelect extends PureComponent<Props, State> {
84
85
  return '';
85
86
  }
86
87
 
88
+ getItemsContainerStyle = (): CSSProperties => {
89
+ let {optionsContainerHeight} = this.props;
90
+ if(typeof optionsContainerHeight === 'number') optionsContainerHeight = `${optionsContainerHeight}px`;
91
+ return {maxHeight: optionsContainerHeight};
92
+ }
93
+
87
94
  renderLabel = () => {
88
95
  const {labelClassName, label} = this.props;
89
96
  if (!label) return null;
@@ -118,7 +125,7 @@ export default class DvrdSelect extends PureComponent<Props, State> {
118
125
  return (
119
126
  <div
120
127
  className={classNames('dvrd-select-items', (open && !disabled) && 'open', itemsPosition,
121
- itemContainerClassName)}>
128
+ itemContainerClassName)} style={this.getItemsContainerStyle()}>
122
129
  {items.filter((item) => item.label.toString().length > 0 && item.selectable !== false)
123
130
  .map((item: SelectItemShape, index: number) => (
124
131
  <label key={index} className={classNames('dvrd-select-item', itemClassName)}
@@ -23,6 +23,7 @@ interface Props {
23
23
  itemClassName?: string;
24
24
  itemsPosition: 'top' | 'bottom';
25
25
  selectOnly: boolean;
26
+ optionsContainerHeight: number | string;
26
27
  }
27
28
 
28
29
  interface State {
@@ -35,6 +36,7 @@ export default class DvrdSelectController extends PureComponent<Props, State> {
35
36
  static defaultProps = {
36
37
  itemsPosition: 'bottom',
37
38
  selectOnly: true,
39
+ optionsContainerHeight: '15rem',
38
40
  };
39
41
 
40
42
  state: State = {
@@ -63,7 +65,7 @@ export default class DvrdSelectController extends PureComponent<Props, State> {
63
65
  render = () => {
64
66
  const {
65
67
  arrowClassName, label, error, className, labelClassName, valueClassName, itemContainerClassName,
66
- itemClassName, errorClassName, disabled, value, itemsPosition, selectOnly
68
+ itemClassName, errorClassName, disabled, value, itemsPosition, selectOnly, optionsContainerHeight
67
69
  } = this.props, {searchValue} = this.state;
68
70
  return (
69
71
  <DvrdSelect onChange={this.onChange} value={value} items={this.getItems()} disabled={disabled}
@@ -72,7 +74,8 @@ export default class DvrdSelectController extends PureComponent<Props, State> {
72
74
  labelClassName={labelClassName} className={className} error={error} label={label}
73
75
  arrowClassName={arrowClassName} itemsPosition={itemsPosition} ref={(ref: DvrdSelect) => {
74
76
  this.select = ref
75
- }} searchValue={searchValue} onChangeSearch={this.onChangeSearch} selectOnly={selectOnly}/>
77
+ }} searchValue={searchValue} onChangeSearch={this.onChangeSearch} selectOnly={selectOnly}
78
+ optionsContainerHeight={optionsContainerHeight}/>
76
79
  );
77
80
  }
78
81
  };
@@ -65,6 +65,7 @@
65
65
  flex-direction: column;
66
66
  min-width: 100%;
67
67
  border-radius: .5rem;
68
+ overflow-y: auto;
68
69
 
69
70
  .dvrd-select-item {
70
71
  padding: .75rem;
@@ -33,6 +33,7 @@ interface Props {
33
33
  asCurrency: boolean;
34
34
  autoSelect?: boolean;
35
35
  }
36
+ // TODO Add option to disable symbols (+,-)
36
37
 
37
38
  export default class DvrdNumberInput extends PureComponent<Props> {
38
39
  static defaultProps = {