react-ui-basics 0.0.189 → 0.0.190

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": "react-ui-basics",
3
- "version": "0.0.189",
3
+ "version": "0.0.190",
4
4
  "description": "",
5
5
  "module": "index.js",
6
6
  "_main": "index.cjs.js",
@@ -22,6 +22,7 @@ import {
22
22
  import Button from "./Button";
23
23
  import MaterialIcon from "./MaterialIcon";
24
24
  import {PureComponent} from "./ReactConstants";
25
+ import ReactDOM from "react-dom";
25
26
 
26
27
  export const MODE_DEFAULT = 'default';
27
28
  export const MODE_INLINE = 'inline';
@@ -99,7 +100,9 @@ class AutocompleteSelect extends PureComponent {
99
100
  componentDidMount() {
100
101
  addEventListener(DOCUMENT, 'mousedown', this.listener = (e) => {
101
102
  if (__state(this).isActive && this.el && !this.el.contains(__target(e))) {
102
- this.onClickOutside()
103
+ if(!__props(this).listPortal || !this.list?.el?.el || !this.list.el.el.contains(__target(e))){
104
+ this.onClickOutside()
105
+ }
103
106
  }
104
107
  })
105
108
  if (__props(this).required) {
@@ -112,11 +115,29 @@ class AutocompleteSelect extends PureComponent {
112
115
  }
113
116
  }
114
117
  this.initSelected(__props(this), __state(this))
118
+ this.updateListPosition()
119
+ }
120
+
121
+ updateListPosition = () => {
122
+ if (__props(this).listPortal && __state(this).isActive) {
123
+ var rect = this.el.getBoundingClientRect();
124
+ this.setState({
125
+ listStyles: {
126
+ position: 'absolute',
127
+ top: rect.bottom + 'px',
128
+ left: __left(rect) + 'px',
129
+ minWidth: __width(rect) + 'px',
130
+ maxHeight: '300px',
131
+ }
132
+ })
133
+ }
115
134
  }
116
135
 
117
136
  componentDidUpdate(prevProps, prevState, snapshot) {
118
137
  if (__props(this).value !== __value(prevProps))
119
138
  this.initSelected(__props(this), __state(this))
139
+ if (__state(this).isActive && !prevState.isActive)
140
+ this.updateListPosition()
120
141
  }
121
142
 
122
143
  initSelected = ({value, mode, allowCustom}, {filterValue = ''}) => {
@@ -174,11 +195,12 @@ class AutocompleteSelect extends PureComponent {
174
195
  allowCustom,
175
196
  inlineSelected,
176
197
  removeIcon,
198
+ listPortal,
177
199
  } = __props(this);
178
200
  const id = __props(this).id || this.randomId;
179
201
  const selectedComponent = __props(this).selectedComponent || childComponent;
180
202
  const {selected = {}, filterValue = '', errored} = __state(this);
181
- let {isActive} = __state(this);
203
+ let {isActive, listStyles} = __state(this);
182
204
  if (__props(this).isActive !== UNDEFINED) {
183
205
  isActive = __props(this).isActive
184
206
  }
@@ -209,6 +231,26 @@ class AutocompleteSelect extends PureComponent {
209
231
  const dataFiltered = allowCustom ? [filterValueTrimmed, ...data.filter(suggestion => suggestion !== filterValueTrimmed)] : data;
210
232
 
211
233
  const filterFunction = this.createFilter(prefilter, filterValue, filterValueTrimmed.toLowerCase(), filter)
234
+ let filteredList = <FilteredList className={classNames(isActive && 'visible', listPortal && 'portal')}
235
+ style={listStyles}
236
+ ref={ref('list', this)}
237
+ filter={filterFunction}
238
+ selectSingle={!allowCustom}
239
+ scroll={scroll}
240
+ inline={isInline}
241
+ nextProvider={ref('next', this)}
242
+ prevProvider={ref('prev', this)}
243
+ selectedProvider={ref('getSelected', this)}
244
+ resetProvider={ref('reset', this)}
245
+ onSelect={this.onSelect}
246
+ selected={selected}
247
+ childComponent={childComponent}
248
+ childProps={childProps}
249
+ data={dataFiltered}
250
+ labels={labels}
251
+ />;
252
+ filteredList = listPortal ? ReactDOM.createPortal(filteredList, listPortal) : filteredList
253
+
212
254
  return (
213
255
  <div id={id}
214
256
  className={classNames(
@@ -333,23 +375,7 @@ class AutocompleteSelect extends PureComponent {
333
375
  </div>
334
376
  )}
335
377
 
336
- <FilteredList className={classNames(isActive && 'visible')}
337
- ref={ref('list', this)}
338
- filter={filterFunction}
339
- selectSingle={!allowCustom}
340
- scroll={scroll}
341
- inline={isInline}
342
- nextProvider={ref('next', this)}
343
- prevProvider={ref('prev', this)}
344
- selectedProvider={ref('getSelected', this)}
345
- resetProvider={ref('reset', this)}
346
- onSelect={this.onSelect}
347
- selected={selected}
348
- childComponent={childComponent}
349
- childProps={childProps}
350
- data={dataFiltered}
351
- labels={labels}
352
- />
378
+ {filteredList}
353
379
  </div>
354
380
  )
355
381
  }
@@ -18,6 +18,9 @@
18
18
  opacity: 1;
19
19
  visibility: visible;
20
20
  }
21
+ .FilteredList.portal {
22
+ transition: opacity 0.2s ease-out;
23
+ }
21
24
  .FilteredList.inline {
22
25
  max-height: 225px;
23
26
  margin-top: 5px;
@@ -22,6 +22,10 @@
22
22
  }
23
23
  }
24
24
 
25
+ &.portal {
26
+ transition: opacity 0.2s ease-out;
27
+ }
28
+
25
29
  &.inline {
26
30
  max-height: 225px;
27
31
  margin-top: 5px;
package/src/Scrollable.js CHANGED
@@ -2,7 +2,21 @@ import ReactConstants from "./../ReactConstants"; import {clientHeight as __clie
2
2
  import {toConsumableArray as __toConsumableArray} from "./../_virtual/_rollupPluginBabelHelpers"; import {extends as __extends} from "./../_virtual/_rollupPluginBabelHelpers"; import {inherits as __inherits} from "./../_virtual/_rollupPluginBabelHelpers"; import './Scrollable.css'; import ReactCreateElement from './ReactCreateElement';
3
3
  import PropTypes from 'prop-types';
4
4
  import './Scrollable.css'
5
- import {classNames, preventDefault, WINDOW, addEventListener, removeEventListener, setTimeout, clearTimeout, setInterval, clearInterval, createRef, orNoop, NOOP} from "./Tools";
5
+ import {
6
+ classNames,
7
+ preventDefault,
8
+ WINDOW,
9
+ addEventListener,
10
+ removeEventListener,
11
+ setTimeout,
12
+ clearTimeout,
13
+ setInterval,
14
+ clearInterval,
15
+ createRef,
16
+ orNoop,
17
+ NOOP,
18
+ ref
19
+ } from "./Tools";
6
20
  import {propsGetter, stateGS, PureComponent, render, componentDidMount, componentDidUpdate, componentWillUnmount} from "./ReactConstants";
7
21
 
8
22
  export const SCROLLBAR_MODE_HIDDEN = 'hidden';
@@ -36,7 +50,6 @@ class Scrollable extends PureComponent {
36
50
  const status = stateGS(that);
37
51
  const statusH = stateGS(that);
38
52
 
39
- const containerRef = createRef();
40
53
  const viewportRef = createRef();
41
54
  const scrollbarRef = createRef();
42
55
  const horizontalScrollbarRef = createRef();
@@ -63,7 +76,7 @@ class Scrollable extends PureComponent {
63
76
  const viewport = viewportRef();
64
77
  const scrollbar = scrollbarRef();
65
78
  const scrollbarH = horizontalScrollbarRef();
66
- const container = containerRef();
79
+ const container = that.el;
67
80
  const thumb = thumbRef();
68
81
  const thumbH = horizontalThumbRef();
69
82
 
@@ -340,13 +353,13 @@ class Scrollable extends PureComponent {
340
353
  };
341
354
  that.getScroll = () => __scrollTop(viewportRef());
342
355
  that.getScrollHeight = () => scrollHeightOf(viewportRef());
343
- that.getHeight = () => __clientHeight(containerRef());
356
+ that.getHeight = () => that.el.clientHeight;
344
357
 
345
358
  that[ReactConstants[3]] = () => {
346
359
  const _props = props();
347
360
  const {className, children} = _props;
348
361
  return (
349
- <div className={classNames('Scrollable', className, status() || WITH_SCROLL, statusH() + '-horizontal')} style={styleOf(_props)} ref={containerRef}>
362
+ <div className={classNames('Scrollable', className, status() || WITH_SCROLL, statusH() + '-horizontal')} style={styleOf(_props)} ref={ref('el', this)}>
350
363
  <div className="viewport" ref={viewportRef}>
351
364
  {children}
352
365
  </div>
package/src/Table.css CHANGED
@@ -92,3 +92,9 @@
92
92
  padding: 0px;
93
93
  background-color: rgb(240, 240, 240);
94
94
  }
95
+ .Table .editable > .AutocompleteSelect {
96
+ min-width: unset;
97
+ }
98
+ .Table .editable > .AutocompleteSelect > .selected > .DummyChild {
99
+ margin: 0;
100
+ }
package/src/Table.scss CHANGED
@@ -116,6 +116,14 @@
116
116
  background-color: rgb(240, 240, 240);
117
117
  }
118
118
  }
119
+
120
+ > .AutocompleteSelect{
121
+ min-width: unset;
122
+
123
+ > .selected > .DummyChild {
124
+ margin: 0;
125
+ }
126
+ }
119
127
  }
120
128
 
121
129
  }
package/src/Table.tsx CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  createRef,
16
16
  setInterval,
17
17
  createAccessor,
18
- UNDEFINED
18
+ UNDEFINED, DOCUMENT
19
19
  } from "./Tools";
20
20
  import MaterialIcon from "./MaterialIcon";
21
21
  import {componentDidUpdate, componentWillUnmount, render, PureComponent, propsGetter, componentDidMount, stateGSs, stateGS} from "./ReactConstants";
@@ -296,6 +296,7 @@ export interface TableColumnSelect<T> extends TableColumn<T> {
296
296
  editorSelectedComponent?: any,
297
297
  editorChildComponent?: any,
298
298
  prefilter?: any,
299
+ filter?: (value: any, filterValue: string) => boolean,
299
300
  }
300
301
 
301
302
  class Row<T> extends PureComponent<RowProps<T>> {
@@ -358,7 +359,7 @@ class Row<T> extends PureComponent<RowProps<T>> {
358
359
  data={(column as TableColumnSelect<T>).editorData}
359
360
  focused={true}
360
361
  withArrow={false}
361
- withFilter={false}
362
+ withFilter={true}
362
363
  selectedMode={'inline'}
363
364
  selectedComponent={(column as TableColumnSelect<T>).editorSelectedComponent}
364
365
  mode={(column as TableColumnSelect<T>).multiSelect ? MODE_MULTIPLE_MINI : MODE_DEFAULT}
@@ -371,6 +372,8 @@ class Row<T> extends PureComponent<RowProps<T>> {
371
372
  childComponent={(column as TableColumnSelect<T>).editorChildComponent}
372
373
  onCancel={cancelEditing}
373
374
  prefilter={(column as TableColumnSelect<T>).prefilter}
375
+ filter={(column as TableColumnSelect<T>).filter}
376
+ listPortal={DOCUMENT.body}
374
377
  />
375
378
  )}
376
379
  {displayEditor && column.editor === editorSwitch && (