react-ui-basics 0.0.229 → 0.0.231
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/AutocompleteSelect.js +34 -23
- package/AutocompleteSelect.js.map +1 -1
- package/FilteredList.css +0 -1
- package/FilteredList.d.ts +2 -3
- package/FilteredList.js +13 -24
- package/FilteredList.js.map +1 -1
- package/bundle.css +476 -477
- package/package.json +1 -1
- package/router/Link.js +5 -7
- package/router/Link.js.map +1 -1
- package/router/NavLink.js +7 -5
- package/router/NavLink.js.map +1 -1
- package/src/AutocompleteSelect.js +18 -10
- package/src/FilteredList.css +0 -1
- package/src/FilteredList.scss +0 -1
- package/src/FilteredList.tsx +16 -28
- package/src/router/Link.tsx +4 -5
- package/src/router/NavLink.tsx +10 -6
package/package.json
CHANGED
package/router/Link.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import ReactConstants from "./../ReactConstants"; import {clientHeight as __clientHeight, clientWidth as __clientWidth, createAccessor as __createAccessor, data as __data, height as __height, left as __left, length as __length, pageX as __pageX, pageY as __pageY, props as __props, scrollLeft as __scrollLeft, scrollTop as __scrollTop, state as __state, style as __style, target as __target, top as __top, value as __value, width as __width} from "./../CommonFields"; import {toConsumableArray as __toConsumableArray} from "./../_virtual/_rollupPluginBabelHelpers"; import {extends as __extends} from "./../_virtual/_rollupPluginBabelHelpers"; import {inherits as __inherits} from "./../_virtual/_rollupPluginBabelHelpers";
|
|
2
|
-
import { jsx as jsxRuntime_2 } from '../../../node_modules/react/jsx-runtime.js';
|
|
1
|
+
import ReactConstants from "./../ReactConstants"; import {clientHeight as __clientHeight, clientWidth as __clientWidth, createAccessor as __createAccessor, data as __data, height as __height, left as __left, length as __length, pageX as __pageX, pageY as __pageY, props as __props, scrollLeft as __scrollLeft, scrollTop as __scrollTop, state as __state, style as __style, target as __target, top as __top, value as __value, width as __width} from "./../CommonFields"; import {toConsumableArray as __toConsumableArray} from "./../_virtual/_rollupPluginBabelHelpers"; import {extends as __extends} from "./../_virtual/_rollupPluginBabelHelpers"; import {inherits as __inherits} from "./../_virtual/_rollupPluginBabelHelpers"; import { jsx as jsxRuntime_2 } from '../../../node_modules/react/jsx-runtime.js';
|
|
3
2
|
import { pushLocation } from './HistoryTools.js';
|
|
4
3
|
import { preventDefault } from '../Tools.js';
|
|
5
4
|
|
|
6
|
-
const Link = (
|
|
7
|
-
|
|
8
|
-
return jsxRuntime_2("a", __extends({ href: href, [ReactConstants[5]]: className }, other, { [ReactConstants[6]]: (e) => {
|
|
5
|
+
const Link = (props) => {
|
|
6
|
+
return jsxRuntime_2("a", __extends({}, props, { [ReactConstants[6]]: (e) => {
|
|
9
7
|
if (!e.ctrlKey) {
|
|
10
8
|
preventDefault(e);
|
|
11
|
-
pushLocation(href);
|
|
9
|
+
pushLocation(props.href);
|
|
12
10
|
}
|
|
13
|
-
} }
|
|
11
|
+
} }));
|
|
14
12
|
};
|
|
15
13
|
var Link$1 = Link;
|
|
16
14
|
|
package/router/Link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.js","sources":["../src/router/Link.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Link.js","sources":["../src/router/Link.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;AAUA,MAAM,IAAI,GAAwB,CAAC,KAAK,KAAI;IACxC,OAAOA,YAAA,CAAA,GAAA,EAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAO,KAAK,EAAE,EAAA,OAAO,EAAE,CAAC,CAAC,KAAI;AAChC,YAAA,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE;gBACZ,cAAc,CAAC,CAAC,CAAC,CAAC;AAClB,gBAAA,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC5B,aAAA;AACL,SAAC,IAAG,CAAC;AACT,CAAC,CAAC;AAEF,aAAe,IAAI;;;;"}
|
package/router/NavLink.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import ReactConstants from "./../ReactConstants"; import {clientHeight as __clientHeight, clientWidth as __clientWidth, createAccessor as __createAccessor, data as __data, height as __height, left as __left, length as __length, pageX as __pageX, pageY as __pageY, props as __props, scrollLeft as __scrollLeft, scrollTop as __scrollTop, state as __state, style as __style, target as __target, top as __top, value as __value, width as __width} from "./../CommonFields"; import {toConsumableArray as __toConsumableArray} from "./../_virtual/_rollupPluginBabelHelpers"; import {extends as __extends} from "./../_virtual/_rollupPluginBabelHelpers"; import {inherits as __inherits} from "./../_virtual/_rollupPluginBabelHelpers";
|
|
2
|
-
import { jsx as jsxRuntime_2 } from '../../../node_modules/react/jsx-runtime.js';
|
|
1
|
+
import ReactConstants from "./../ReactConstants"; import {clientHeight as __clientHeight, clientWidth as __clientWidth, createAccessor as __createAccessor, data as __data, height as __height, left as __left, length as __length, pageX as __pageX, pageY as __pageY, props as __props, scrollLeft as __scrollLeft, scrollTop as __scrollTop, state as __state, style as __style, target as __target, top as __top, value as __value, width as __width} from "./../CommonFields"; import {toConsumableArray as __toConsumableArray} from "./../_virtual/_rollupPluginBabelHelpers"; import {extends as __extends} from "./../_virtual/_rollupPluginBabelHelpers"; import {inherits as __inherits} from "./../_virtual/_rollupPluginBabelHelpers"; import { jsx as jsxRuntime_2 } from '../../../node_modules/react/jsx-runtime.js';
|
|
3
2
|
import './HistoryTools.js';
|
|
4
3
|
import Route from './Route.js';
|
|
5
4
|
import Link from './Link.js';
|
|
6
5
|
import { classNames } from '../Tools.js';
|
|
7
6
|
|
|
8
|
-
const NavLink = (
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const NavLink = (props) => {
|
|
8
|
+
const { href, highlightPath, className, activeClassName } = props;
|
|
9
|
+
const other = __extends({}, props);
|
|
10
|
+
delete other.activeClassName;
|
|
11
|
+
delete other.highlightPath;
|
|
12
|
+
return jsxRuntime_2(Route, { path: highlightPath || href, controller: matches => jsxRuntime_2(Link, __extends({}, props, { [ReactConstants[5]]: classNames(className, matches && activeClassName) })) });
|
|
11
13
|
};
|
|
12
14
|
var NavLink$1 = NavLink;
|
|
13
15
|
|
package/router/NavLink.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavLink.js","sources":["../src/router/NavLink.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"NavLink.js","sources":["../src/router/NavLink.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;;AAYA,MAAM,OAAO,GAA2B,CAAC,KAAK,KAAI;IAC9C,MAAM,EAAC,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAC,GAAG,KAAK,CAAC;AAChE,IAAA,MAAM,KAAK,GAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAO,KAAK,CAAC,CAAA;IACxB,OAAO,KAAK,CAAC,eAAe,CAAA;IAC5B,OAAO,KAAK,CAAC,aAAa,CAAA;AAE1B,IAAA,OAAOA,YAAC,CAAA,KAAK,EACT,EAAA,IAAI,EAAE,aAAa,IAAI,IAAI,EAC3B,UAAU,EAAE,OAAO,IAAIA,YAAA,CAAC,IAAI,EAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAK,KAAK,EAAA,EAAE,SAAS,EAAE,UAAU,CAAC,SAAS,EAAE,OAAO,IAAI,eAAe,CAAC,EAAA,CAAA,CAAG,GACzG,CAAC;AACP,CAAC,CAAC;AAEF,gBAAe,OAAO;;;;"}
|
|
@@ -163,6 +163,7 @@ class AutocompleteSelect extends PureComponent {
|
|
|
163
163
|
childComponent: DummyChild,
|
|
164
164
|
withArrow: true,
|
|
165
165
|
withFilter: true,
|
|
166
|
+
selectCustomOnClickOutside: true,
|
|
166
167
|
withReset: false,
|
|
167
168
|
scrollToValue: false,
|
|
168
169
|
mode: MODE_DEFAULT,
|
|
@@ -223,7 +224,7 @@ class AutocompleteSelect extends PureComponent {
|
|
|
223
224
|
const hasSelected = __length(selectedIds) !== 0;
|
|
224
225
|
const setActive = (e) => {
|
|
225
226
|
stopPropagation(e);
|
|
226
|
-
this.setState({isActive: true}, () => (scrollToValue && __length(selectedIds) > 0) && this.list.
|
|
227
|
+
this.setState({isActive: true}, () => (scrollToValue && __length(selectedIds) > 0) && this.list.selected(selectedIds[0]));
|
|
227
228
|
};
|
|
228
229
|
const toggle = (e) => {
|
|
229
230
|
if (!__state(this).isActive) {
|
|
@@ -236,9 +237,9 @@ class AutocompleteSelect extends PureComponent {
|
|
|
236
237
|
|
|
237
238
|
const isInline = mode === MODE_INLINE || mode === MODE_INLINE_MULTIPLE || mode === MODE_MULTIPLE_MINI_INLINE;
|
|
238
239
|
const filterValueTrimmed = filterValue.trim();
|
|
239
|
-
const dataFiltered = allowCustom ? [filterValueTrimmed, ...data.filter(suggestion => suggestion !== filterValueTrimmed)] : data;
|
|
240
|
+
const dataFiltered = allowCustom && !scrollToValue ? [filterValueTrimmed, ...data.filter(suggestion => suggestion !== filterValueTrimmed)] : data;
|
|
240
241
|
|
|
241
|
-
const filterFunction = this.createFilter(prefilter, filterValue, filterValueTrimmed.toLowerCase(), filter)
|
|
242
|
+
const filterFunction = !scrollToValue ? this.createFilter(prefilter, filterValue, filterValueTrimmed.toLowerCase(), filter) : UNDEFINED
|
|
242
243
|
let filteredList = <FilteredList className={classNames(isActive && 'visible', listPortal && 'portal')}
|
|
243
244
|
style={listStyles}
|
|
244
245
|
ref={ref('list', this)}
|
|
@@ -371,7 +372,7 @@ class AutocompleteSelect extends PureComponent {
|
|
|
371
372
|
} else if (keyCode === 27/*esc*/) {
|
|
372
373
|
this.setState({
|
|
373
374
|
isActive: false,
|
|
374
|
-
filterValue: isMultipleSelect(mode) ? '' : (
|
|
375
|
+
filterValue: isMultipleSelect(mode) ? '' : Object.values(selected)[0] || '',
|
|
375
376
|
});
|
|
376
377
|
this.input.getInput().blur()
|
|
377
378
|
this.onCancel();
|
|
@@ -389,14 +390,15 @@ class AutocompleteSelect extends PureComponent {
|
|
|
389
390
|
}
|
|
390
391
|
|
|
391
392
|
onClickOutside = () => {
|
|
392
|
-
const {allowCustom, required, onFilterInputChange} = __props(this);
|
|
393
|
-
|
|
394
|
-
if (allowCustom && (!!filterValue || !required)) {
|
|
395
|
-
this.onSelect()
|
|
393
|
+
const {allowCustom, required, onFilterInputChange, mode, selectCustomOnClickOutside} = __props(this);
|
|
394
|
+
let {filterValue, selected} = __state(this);
|
|
395
|
+
if (allowCustom && selectCustomOnClickOutside && (!!filterValue || !required)) {
|
|
396
|
+
selected = this.onSelect()
|
|
396
397
|
}
|
|
397
398
|
|
|
398
|
-
|
|
399
|
-
|
|
399
|
+
filterValue = (!isMultipleSelect(mode) && Object.values(selected)[0]) || ''
|
|
400
|
+
this.setState({isActive: false, filterValue});
|
|
401
|
+
onFilterInputChange && onFilterInputChange(filterValue);
|
|
400
402
|
|
|
401
403
|
this.onCancel();
|
|
402
404
|
};
|
|
@@ -466,6 +468,7 @@ class AutocompleteSelect extends PureComponent {
|
|
|
466
468
|
|
|
467
469
|
orNoop(onSelect)(selectedId);
|
|
468
470
|
orNoop(onChange)(Object.values(selected));
|
|
471
|
+
return selected
|
|
469
472
|
};
|
|
470
473
|
|
|
471
474
|
clean = (e) => {
|
|
@@ -498,6 +501,11 @@ class AutocompleteSelect extends PureComponent {
|
|
|
498
501
|
onChange = (event) => {
|
|
499
502
|
const value = __target(event).value;
|
|
500
503
|
this.setState({filterValue: value});
|
|
504
|
+
const data = __state(this).data || __props(this).data || []
|
|
505
|
+
if (data.indexOf(value) !== -1) {
|
|
506
|
+
this.list.selected(value)
|
|
507
|
+
}
|
|
508
|
+
|
|
501
509
|
__props(this).onFilterInputChange?.(value);
|
|
502
510
|
}
|
|
503
511
|
}
|
package/src/FilteredList.css
CHANGED
package/src/FilteredList.scss
CHANGED
package/src/FilteredList.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import React, {CSSProperties, MouseEventHandler} from 'react';
|
|
|
2
2
|
import ReactCreateElement from './ReactCreateElement';
|
|
3
3
|
import './FilteredList.css'
|
|
4
4
|
import Scrollable from "./Scrollable";
|
|
5
|
-
import {classNames, orNoop, ref, stopPropagation, isFunction, isObject} from "./Tools";
|
|
5
|
+
import {classNames, orNoop, ref, stopPropagation, isFunction, isObject, UNDEFINED} from "./Tools";
|
|
6
6
|
import {PureComponent} from "./ReactConstants";
|
|
7
7
|
|
|
8
8
|
type Labels<T> = ((item: T) => string) | { [key: string]: string } | { [key: number]: string };
|
|
@@ -44,9 +44,9 @@ class FilteredList<T extends string|number> extends PureComponent<FilteredListPr
|
|
|
44
44
|
filter: () => true,
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
hidden:Map<T, boolean> = new Map();
|
|
48
|
-
elements
|
|
49
|
-
list:T[] = [];
|
|
47
|
+
hidden: Map<T, boolean> = new Map();
|
|
48
|
+
elements: Map<T, HTMLDivElement> = new Map();
|
|
49
|
+
list: T[] = [];
|
|
50
50
|
el: Scrollable
|
|
51
51
|
|
|
52
52
|
constructor(props) {
|
|
@@ -114,7 +114,12 @@ class FilteredList<T extends string|number> extends PureComponent<FilteredListPr
|
|
|
114
114
|
this.props.onSelect(id);
|
|
115
115
|
};
|
|
116
116
|
|
|
117
|
-
selected = (): T => {
|
|
117
|
+
selected = (id?: T): T => {
|
|
118
|
+
if (id !== UNDEFINED) {
|
|
119
|
+
this.setState({selected: id});
|
|
120
|
+
this.scrollTo(id)
|
|
121
|
+
return id;
|
|
122
|
+
}
|
|
118
123
|
const {selected: value} = this.state;
|
|
119
124
|
const {selectSingle} = this.props;
|
|
120
125
|
|
|
@@ -144,7 +149,7 @@ class FilteredList<T extends string|number> extends PureComponent<FilteredListPr
|
|
|
144
149
|
if (position < list.length) {
|
|
145
150
|
let id = list[position];
|
|
146
151
|
this.setState({selected: id});
|
|
147
|
-
this.
|
|
152
|
+
this.scrollTo(id)
|
|
148
153
|
}
|
|
149
154
|
};
|
|
150
155
|
|
|
@@ -162,27 +167,7 @@ class FilteredList<T extends string|number> extends PureComponent<FilteredListPr
|
|
|
162
167
|
if (position >= 0) {
|
|
163
168
|
let id = list[position];
|
|
164
169
|
this.setState({selected: id});
|
|
165
|
-
this.
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
updateScroll = (id) => {
|
|
170
|
-
const child = this.elements[id];
|
|
171
|
-
if (!child)
|
|
172
|
-
return
|
|
173
|
-
|
|
174
|
-
const container = this.el;
|
|
175
|
-
const scrollTop = container.getScroll();
|
|
176
|
-
const height = container.getHeight();
|
|
177
|
-
let isVisible = scrollTop <= child.offsetTop && scrollTop + height >= child.offsetTop + child.clientHeight;
|
|
178
|
-
if (!isVisible) {
|
|
179
|
-
let scrollToBottom = child.offsetTop + child.clientHeight - height;
|
|
180
|
-
let scrollToTop = child.offsetTop;
|
|
181
|
-
if (Math.abs(scrollTop - scrollToTop) < Math.abs(scrollTop - scrollToBottom)) {
|
|
182
|
-
container.setScroll(scrollToTop)
|
|
183
|
-
} else {
|
|
184
|
-
container.setScroll(scrollToBottom)
|
|
185
|
-
}
|
|
170
|
+
this.scrollTo(id)
|
|
186
171
|
}
|
|
187
172
|
};
|
|
188
173
|
|
|
@@ -191,7 +176,10 @@ class FilteredList<T extends string|number> extends PureComponent<FilteredListPr
|
|
|
191
176
|
this.el.setScroll(0)
|
|
192
177
|
};
|
|
193
178
|
|
|
194
|
-
scrollTo = (id) =>
|
|
179
|
+
scrollTo = (id: T) => {
|
|
180
|
+
const child = this.elements.get(id);
|
|
181
|
+
child && this.el.setScroll(child.offsetTop - (this.el.getHeight() - child.clientHeight) / 2);
|
|
182
|
+
};
|
|
195
183
|
}
|
|
196
184
|
|
|
197
185
|
export default FilteredList;
|
package/src/router/Link.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import ReactCreateElement from '../ReactCreateElement';
|
|
3
2
|
import './HistoryTools'
|
|
4
3
|
import {pushLocation} from "./HistoryTools";
|
|
5
4
|
import {preventDefault} from "../Tools";
|
|
@@ -9,13 +8,13 @@ export interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement>
|
|
|
9
8
|
className?: string
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
const Link: React.FC<LinkProps> = (
|
|
13
|
-
return <a
|
|
11
|
+
const Link: React.FC<LinkProps> = (props) => {
|
|
12
|
+
return <a {...props} onClick={(e) => {
|
|
14
13
|
if (!e.ctrlKey) {
|
|
15
14
|
preventDefault(e);
|
|
16
|
-
pushLocation(href);
|
|
15
|
+
pushLocation(props.href);
|
|
17
16
|
}
|
|
18
|
-
}}
|
|
17
|
+
}}/>;
|
|
19
18
|
};
|
|
20
19
|
|
|
21
20
|
export default Link;
|
package/src/router/NavLink.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import ReactCreateElement from '../ReactCreateElement';
|
|
3
2
|
import './HistoryTools'
|
|
4
3
|
import Route from "./Route";
|
|
5
4
|
import Link, {LinkProps} from "./Link";
|
|
@@ -11,11 +10,16 @@ export interface NavLinkProps extends LinkProps {
|
|
|
11
10
|
highlightPath?: string
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
const NavLink: React.FC<NavLinkProps> = (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
const NavLink: React.FC<NavLinkProps> = (props) => {
|
|
14
|
+
const {href, highlightPath, className, activeClassName} = props;
|
|
15
|
+
const other = {...props}
|
|
16
|
+
delete other.activeClassName
|
|
17
|
+
delete other.highlightPath
|
|
18
|
+
|
|
19
|
+
return <Route
|
|
20
|
+
path={highlightPath || href}
|
|
21
|
+
controller={matches => <Link {...props} className={classNames(className, matches && activeClassName)}/>}
|
|
19
22
|
/>;
|
|
23
|
+
};
|
|
20
24
|
|
|
21
25
|
export default NavLink;
|