superdesk-ui-framework 3.0.43 → 3.0.45
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/app-typescript/components/Menu.tsx +1 -1
- package/app-typescript/components/{TreeSelect.tsx → TreeSelect/TreeSelect.tsx} +228 -257
- package/app-typescript/components/TreeSelect/TreeSelectItem.tsx +84 -0
- package/app-typescript/components/TreeSelect/TreeSelectPill.tsx +53 -0
- package/app-typescript/index.ts +1 -1
- package/dist/examples.bundle.js +1026 -913
- package/dist/react/TreeSelect.tsx +1 -1
- package/dist/superdesk-ui.bundle.js +773 -660
- package/dist/vendor.bundle.js +23 -23
- package/examples/pages/react/TreeSelect.tsx +1 -1
- package/package.json +1 -1
- package/react/components/Menu.js +1 -1
- package/react/components/{TreeSelect.d.ts → TreeSelect/TreeSelect.d.ts} +2 -2
- package/react/components/{TreeSelect.js → TreeSelect/TreeSelect.js} +82 -144
- package/react/components/TreeSelect/TreeSelectItem.d.ts +20 -0
- package/react/components/TreeSelect/TreeSelectItem.js +90 -0
- package/react/components/TreeSelect/TreeSelectPill.d.ts +14 -0
- package/react/components/TreeSelect/TreeSelectPill.js +71 -0
- package/react/index.d.ts +1 -1
- package/react/index.js +1 -1
package/dist/vendor.bundle.js
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
var a = typeof exports === 'object' ? factory(require("react"), require("react-dom")) : factory(root["react"], root["react-dom"]);
|
8
8
|
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
9
9
|
}
|
10
|
-
})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_0__,
|
10
|
+
})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_8__) {
|
11
11
|
return /******/ (function(modules) { // webpackBootstrap
|
12
12
|
/******/ // The module cache
|
13
13
|
/******/ var installedModules = {};
|
@@ -70,7 +70,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
70
70
|
/******/ __webpack_require__.p = "";
|
71
71
|
/******/
|
72
72
|
/******/ // Load entry module and return exports
|
73
|
-
/******/ return __webpack_require__(__webpack_require__.s =
|
73
|
+
/******/ return __webpack_require__(__webpack_require__.s = 571);
|
74
74
|
/******/ })
|
75
75
|
/************************************************************************/
|
76
76
|
/******/ ({
|
@@ -17296,7 +17296,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE_0__;
|
|
17296
17296
|
}
|
17297
17297
|
}.call(this));
|
17298
17298
|
|
17299
|
-
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(35), __webpack_require__(
|
17299
|
+
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(35), __webpack_require__(53)(module)))
|
17300
17300
|
|
17301
17301
|
/***/ }),
|
17302
17302
|
|
@@ -17328,7 +17328,7 @@ module.exports = g;
|
|
17328
17328
|
|
17329
17329
|
/***/ }),
|
17330
17330
|
|
17331
|
-
/***/
|
17331
|
+
/***/ 43:
|
17332
17332
|
/***/ (function(module, exports, __webpack_require__) {
|
17333
17333
|
|
17334
17334
|
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
|
@@ -28217,7 +28217,7 @@ return jQuery;
|
|
28217
28217
|
|
28218
28218
|
/***/ }),
|
28219
28219
|
|
28220
|
-
/***/
|
28220
|
+
/***/ 53:
|
28221
28221
|
/***/ (function(module, exports) {
|
28222
28222
|
|
28223
28223
|
module.exports = function(module) {
|
@@ -28246,7 +28246,7 @@ module.exports = function(module) {
|
|
28246
28246
|
|
28247
28247
|
/***/ }),
|
28248
28248
|
|
28249
|
-
/***/
|
28249
|
+
/***/ 571:
|
28250
28250
|
/***/ (function(module, exports, __webpack_require__) {
|
28251
28251
|
|
28252
28252
|
"use strict";
|
@@ -28254,21 +28254,21 @@ module.exports = function(module) {
|
|
28254
28254
|
|
28255
28255
|
__webpack_require__(21);
|
28256
28256
|
|
28257
|
-
__webpack_require__(
|
28258
|
-
|
28259
|
-
__webpack_require__(570);
|
28257
|
+
__webpack_require__(43);
|
28260
28258
|
|
28261
28259
|
__webpack_require__(572);
|
28262
28260
|
|
28263
28261
|
__webpack_require__(574);
|
28264
28262
|
|
28263
|
+
__webpack_require__(576);
|
28264
|
+
|
28265
28265
|
__webpack_require__(0);
|
28266
28266
|
|
28267
|
-
__webpack_require__(
|
28267
|
+
__webpack_require__(8);
|
28268
28268
|
|
28269
28269
|
/***/ }),
|
28270
28270
|
|
28271
|
-
/***/
|
28271
|
+
/***/ 572:
|
28272
28272
|
/***/ (function(module, exports, __webpack_require__) {
|
28273
28273
|
|
28274
28274
|
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
|
@@ -28292,7 +28292,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
28292
28292
|
if ( true ) {
|
28293
28293
|
|
28294
28294
|
// AMD. Register as an anonymous module.
|
28295
|
-
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(
|
28295
|
+
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(43), __webpack_require__(573) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
|
28296
28296
|
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
|
28297
28297
|
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
|
28298
28298
|
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
@@ -29030,7 +29030,7 @@ return $.widget;
|
|
29030
29030
|
|
29031
29031
|
/***/ }),
|
29032
29032
|
|
29033
|
-
/***/
|
29033
|
+
/***/ 573:
|
29034
29034
|
/***/ (function(module, exports, __webpack_require__) {
|
29035
29035
|
|
29036
29036
|
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;( function( factory ) {
|
@@ -29039,7 +29039,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
29039
29039
|
if ( true ) {
|
29040
29040
|
|
29041
29041
|
// AMD. Register as an anonymous module.
|
29042
|
-
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(
|
29042
|
+
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(43) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
|
29043
29043
|
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
|
29044
29044
|
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
|
29045
29045
|
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
@@ -29060,16 +29060,16 @@ return $.ui.version = "1.13.0";
|
|
29060
29060
|
|
29061
29061
|
/***/ }),
|
29062
29062
|
|
29063
|
-
/***/
|
29063
|
+
/***/ 574:
|
29064
29064
|
/***/ (function(module, exports, __webpack_require__) {
|
29065
29065
|
|
29066
|
-
__webpack_require__(
|
29066
|
+
__webpack_require__(575);
|
29067
29067
|
module.exports = angular;
|
29068
29068
|
|
29069
29069
|
|
29070
29070
|
/***/ }),
|
29071
29071
|
|
29072
|
-
/***/
|
29072
|
+
/***/ 575:
|
29073
29073
|
/***/ (function(module, exports, __webpack_require__) {
|
29074
29074
|
|
29075
29075
|
/* WEBPACK VAR INJECTION */(function(__webpack_provided_window_dot_jQuery) {/**
|
@@ -65672,20 +65672,20 @@ $provide.value("$locale", {
|
|
65672
65672
|
})(window);
|
65673
65673
|
|
65674
65674
|
!window.angular.$$csp().noInlineStyle && window.angular.element(document.head).prepend(window.angular.element('<style>').text('@charset "UTF-8";[ng\\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak,.ng-hide:not(.ng-hide-animate){display:none !important;}ng\\:form{display:block;}.ng-animate-shim{visibility:hidden;}.ng-anchor{position:absolute;}'));
|
65675
|
-
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(
|
65675
|
+
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(43)))
|
65676
65676
|
|
65677
65677
|
/***/ }),
|
65678
65678
|
|
65679
|
-
/***/
|
65679
|
+
/***/ 576:
|
65680
65680
|
/***/ (function(module, exports, __webpack_require__) {
|
65681
65681
|
|
65682
|
-
__webpack_require__(
|
65682
|
+
__webpack_require__(577);
|
65683
65683
|
module.exports = 'ngAnimate';
|
65684
65684
|
|
65685
65685
|
|
65686
65686
|
/***/ }),
|
65687
65687
|
|
65688
|
-
/***/
|
65688
|
+
/***/ 577:
|
65689
65689
|
/***/ (function(module, exports) {
|
65690
65690
|
|
65691
65691
|
/**
|
@@ -69964,10 +69964,10 @@ angular.module('ngAnimate', [], function initAngularHelpers() {
|
|
69964
69964
|
|
69965
69965
|
/***/ }),
|
69966
69966
|
|
69967
|
-
/***/
|
69967
|
+
/***/ 8:
|
69968
69968
|
/***/ (function(module, exports) {
|
69969
69969
|
|
69970
|
-
module.exports =
|
69970
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_8__;
|
69971
69971
|
|
69972
69972
|
/***/ })
|
69973
69973
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
2
2
|
import * as Markup from '../../js/react';
|
3
3
|
import { PropsList, Prop } from '../../../app-typescript';
|
4
4
|
import { MultiSelect } from '../../../app-typescript/components/MultiSelect';
|
5
|
-
import { ITreeNode, TreeSelect } from '../../../app-typescript/components/TreeSelect';
|
5
|
+
import { ITreeNode, TreeSelect } from '../../../app-typescript/components/TreeSelect/TreeSelect';
|
6
6
|
|
7
7
|
interface IState {
|
8
8
|
value: any;
|
package/package.json
CHANGED
package/react/components/Menu.js
CHANGED
@@ -42,7 +42,7 @@ exports.Menu = void 0;
|
|
42
42
|
var React = __importStar(require("react"));
|
43
43
|
var tieredmenu_1 = require("@superdesk/primereact/tieredmenu");
|
44
44
|
var helpers_1 = require("../helpers");
|
45
|
-
var superdeskTopBarZIndex =
|
45
|
+
var superdeskTopBarZIndex = 1050;
|
46
46
|
function isSeparator(item) {
|
47
47
|
return item['separator'] === true;
|
48
48
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import * as React from "react";
|
2
|
-
import { IInputWrapper } from '
|
2
|
+
import { IInputWrapper } from '../Form/InputWrapper';
|
3
3
|
interface IState<T> {
|
4
4
|
value: Array<T>;
|
5
5
|
options: Array<ITreeNode<T>>;
|
@@ -54,6 +54,7 @@ export declare class TreeSelect<T> extends React.Component<IProps<T>, IState<T>>
|
|
54
54
|
private inputRef;
|
55
55
|
private categoryButtonRef;
|
56
56
|
private openDropdownRef;
|
57
|
+
private treeSelectRef;
|
57
58
|
private htmlId;
|
58
59
|
private popperInstance;
|
59
60
|
constructor(props: IProps<T>);
|
@@ -73,7 +74,6 @@ export declare class TreeSelect<T> extends React.Component<IProps<T>, IState<T>>
|
|
73
74
|
handleBranchValue(event: React.MouseEvent<HTMLButtonElement, MouseEvent>, item: ITreeNode<T>): void;
|
74
75
|
handleTree(event: React.MouseEvent<HTMLLIElement, MouseEvent>, option: ITreeNode<T>): void;
|
75
76
|
backButton(): void;
|
76
|
-
backButtonValue: () => void;
|
77
77
|
recursion(arr: Array<ITreeNode<T>>): void;
|
78
78
|
filteredItem(arr: Array<ITreeNode<T>>): JSX.Element | JSX.Element[] | undefined;
|
79
79
|
branchButton(buttonValue: ITreeNode<T>): JSX.Element;
|
@@ -52,15 +52,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
53
53
|
exports.TreeSelect = void 0;
|
54
54
|
var React = __importStar(require("react"));
|
55
|
-
var Icon_1 = require("
|
56
|
-
var Loader_1 = require("
|
55
|
+
var Icon_1 = require("../Icon");
|
56
|
+
var Loader_1 = require("../Loader");
|
57
57
|
var react_id_generator_1 = __importDefault(require("react-id-generator"));
|
58
58
|
var debounce_1 = __importDefault(require("lodash/debounce"));
|
59
|
-
var Form_1 = require("
|
59
|
+
var Form_1 = require("../Form");
|
60
60
|
var core_1 = require("@popperjs/core");
|
61
61
|
var lodash_1 = require("lodash");
|
62
|
-
var Label_1 = require("
|
63
|
-
var SelectPreview_1 = require("
|
62
|
+
var Label_1 = require("../Label");
|
63
|
+
var SelectPreview_1 = require("../SelectPreview");
|
64
|
+
var TreeSelectPill_1 = require("./TreeSelectPill");
|
65
|
+
var TreeSelectItem_1 = require("./TreeSelectItem");
|
64
66
|
var TreeSelect = /** @class */ (function (_super) {
|
65
67
|
__extends(TreeSelect, _super);
|
66
68
|
function TreeSelect(props) {
|
@@ -79,21 +81,20 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
79
81
|
(_a = _this.categoryButtonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
80
82
|
};
|
81
83
|
_this.onMouseDown = function (event) {
|
82
|
-
var _a
|
83
|
-
if ((((_a = _this.
|
84
|
-
&&
|
84
|
+
var _a;
|
85
|
+
if ((((_a = _this.treeSelectRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.target)) !== true)
|
86
|
+
&& _this.state.openDropdown) {
|
85
87
|
_this.setState({ openDropdown: false });
|
86
88
|
}
|
87
89
|
};
|
88
90
|
_this.onKeyDown = function (e) {
|
89
91
|
if (_this.state.openDropdown && _this.ref.current) {
|
90
92
|
keyboardNavigation(e, _this.ref.current, _this.categoryButtonRef.current ? _this.buttonFocus : _this.inputFocus);
|
91
|
-
if (e.key === 'Backspace') {
|
93
|
+
if (e.key === 'Backspace' && _this.state.activeTree.length > 0) {
|
92
94
|
_this.backButton();
|
93
|
-
_this.
|
94
|
-
|
95
|
-
|
96
|
-
if (className != null) {
|
95
|
+
var lastElement = _this.state.buttonTarget.pop();
|
96
|
+
if (lastElement != null) {
|
97
|
+
var className = (0, TreeSelectItem_1.getPrefixedItemId)(lastElement);
|
97
98
|
var element = document.getElementsByClassName(className)[0];
|
98
99
|
element.focus();
|
99
100
|
}
|
@@ -105,34 +106,25 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
105
106
|
document.addEventListener("mousedown", _this.onMouseDown);
|
106
107
|
document.addEventListener("keydown", _this.onKeyDown);
|
107
108
|
};
|
108
|
-
_this.backButtonValue = function () {
|
109
|
-
var item = _this.state.buttonTree.pop();
|
110
|
-
if (item != null) {
|
111
|
-
_this.setState({
|
112
|
-
buttonValue: item,
|
113
|
-
});
|
114
|
-
}
|
115
|
-
};
|
116
109
|
_this.debounceFn = (0, debounce_1.default)(_this.handleDebounce, 500);
|
117
110
|
_this.state = {
|
118
111
|
value: _this.props.value ? _this.props.value : [],
|
119
112
|
options: _this.props.getOptions ? _this.props.getOptions() : [],
|
120
113
|
firstBranchOptions: _this.props.getOptions ? _this.props.getOptions() : [],
|
114
|
+
searchFieldValue: '',
|
121
115
|
activeTree: [],
|
122
116
|
filterArr: [],
|
123
|
-
searchFieldValue: '',
|
124
117
|
buttonTree: [],
|
118
|
+
buttonTarget: [],
|
125
119
|
buttonValue: null,
|
126
120
|
buttonMouseEvent: false,
|
127
121
|
openDropdown: false,
|
128
122
|
loading: false,
|
129
|
-
buttonTarget: [],
|
130
123
|
};
|
131
124
|
_this.removeClick = _this.removeClick.bind(_this);
|
132
125
|
_this.handleMultiLevel = _this.handleMultiLevel.bind(_this);
|
133
126
|
_this.backButton = _this.backButton.bind(_this);
|
134
127
|
_this.handleButton = _this.handleButton.bind(_this);
|
135
|
-
_this.backButtonValue = _this.backButtonValue.bind(_this);
|
136
128
|
_this.handleTree = _this.handleTree.bind(_this);
|
137
129
|
_this.filteredItem = _this.filteredItem.bind(_this);
|
138
130
|
_this.branchButton = _this.branchButton.bind(_this);
|
@@ -145,6 +137,7 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
145
137
|
_this.inputRef = React.createRef();
|
146
138
|
_this.categoryButtonRef = React.createRef();
|
147
139
|
_this.openDropdownRef = React.createRef();
|
140
|
+
_this.treeSelectRef = React.createRef();
|
148
141
|
_this.popperInstance = null;
|
149
142
|
return _this;
|
150
143
|
}
|
@@ -285,42 +278,38 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
285
278
|
TreeSelect.prototype.handleBranchValue = function (event, item) {
|
286
279
|
var _this = this;
|
287
280
|
if (this.props.allowMultiple) {
|
288
|
-
|
289
|
-
|
290
|
-
|
281
|
+
var checkItem = this.state.value.find(function (valueItem) {
|
282
|
+
return _this.props.getId(valueItem) === _this.props.getId(item.value);
|
283
|
+
});
|
284
|
+
if (!checkItem) {
|
285
|
+
this.setState({ value: __spreadArray(__spreadArray([], this.state.value, true), [item.value], false) });
|
286
|
+
}
|
287
|
+
if (!event.ctrlKey) {
|
288
|
+
this.setState({
|
289
|
+
options: this.state.firstBranchOptions,
|
290
|
+
activeTree: [],
|
291
|
+
buttonTarget: [],
|
292
|
+
openDropdown: false,
|
291
293
|
});
|
292
|
-
if (!checkItem) {
|
293
|
-
this.setState({ value: __spreadArray(__spreadArray([], this.state.value, true), [item.value], false) });
|
294
|
-
}
|
295
|
-
if (!event.ctrlKey) {
|
296
|
-
this.setState({
|
297
|
-
options: this.state.firstBranchOptions,
|
298
|
-
activeTree: [],
|
299
|
-
buttonTarget: [],
|
300
|
-
openDropdown: false,
|
301
|
-
});
|
302
|
-
}
|
303
|
-
this.setState({ buttonMouseEvent: false });
|
304
294
|
}
|
295
|
+
this.setState({ buttonMouseEvent: false });
|
305
296
|
}
|
306
297
|
else {
|
307
|
-
|
308
|
-
|
309
|
-
|
298
|
+
var checkItem = this.state.value.find(function (valueItem) {
|
299
|
+
return _this.props.getId(valueItem) === _this.props.getId(item.value);
|
300
|
+
});
|
301
|
+
if (!checkItem) {
|
302
|
+
this.setState({ value: [item.value] });
|
303
|
+
}
|
304
|
+
if (!event.ctrlKey) {
|
305
|
+
this.setState({
|
306
|
+
options: this.state.firstBranchOptions,
|
307
|
+
activeTree: [],
|
308
|
+
buttonTarget: [],
|
309
|
+
openDropdown: false,
|
310
310
|
});
|
311
|
-
if (!checkItem) {
|
312
|
-
this.setState({ value: [item.value] });
|
313
|
-
}
|
314
|
-
if (!event.ctrlKey) {
|
315
|
-
this.setState({
|
316
|
-
options: this.state.firstBranchOptions,
|
317
|
-
activeTree: [],
|
318
|
-
buttonTarget: [],
|
319
|
-
openDropdown: false,
|
320
|
-
});
|
321
|
-
}
|
322
|
-
this.setState({ buttonMouseEvent: false });
|
323
311
|
}
|
312
|
+
this.setState({ buttonMouseEvent: false });
|
324
313
|
}
|
325
314
|
};
|
326
315
|
TreeSelect.prototype.handleTree = function (event, option) {
|
@@ -380,6 +369,12 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
380
369
|
options: items,
|
381
370
|
});
|
382
371
|
}
|
372
|
+
var item = this.state.buttonTree.pop();
|
373
|
+
if (item != null) {
|
374
|
+
this.setState({
|
375
|
+
buttonValue: item,
|
376
|
+
});
|
377
|
+
}
|
383
378
|
};
|
384
379
|
TreeSelect.prototype.recursion = function (arr) {
|
385
380
|
var _this = this;
|
@@ -396,7 +391,8 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
396
391
|
var filteredArr = arr.filter(function (item) {
|
397
392
|
if (_this.state.searchFieldValue) {
|
398
393
|
if (_this.props.getLabel(item.value)
|
399
|
-
.toLowerCase()
|
394
|
+
.toLowerCase()
|
395
|
+
.includes(_this.state.searchFieldValue.toLowerCase())) {
|
400
396
|
return item.value;
|
401
397
|
}
|
402
398
|
else {
|
@@ -408,38 +404,16 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
408
404
|
}
|
409
405
|
});
|
410
406
|
if (filteredArr.length === 0) {
|
411
|
-
return React.createElement("li", { className: "suggestion-item--nothing-found" }, "Nothing
|
407
|
+
return React.createElement("li", { className: "suggestion-item--nothing-found" }, "Nothing found");
|
412
408
|
}
|
413
409
|
else {
|
414
410
|
return filteredArr.map(function (option, i) {
|
415
411
|
var selectedItem = _this.state.value.some(function (obj) {
|
416
412
|
return _this.props.getId(obj) === _this.props.getId(option.value);
|
417
413
|
});
|
418
|
-
return (React.createElement(
|
419
|
-
|
420
|
-
|
421
|
-
}),
|
422
|
-
event.preventDefault();
|
423
|
-
event.stopPropagation();
|
424
|
-
_this.handleTree(event, option);
|
425
|
-
} },
|
426
|
-
React.createElement("button", { className: "suggestion-item--btn" },
|
427
|
-
_this.props.getBorderColor
|
428
|
-
&& React.createElement("div", { className: "item-border", style: {
|
429
|
-
backgroundColor: _this.props.getBorderColor(option.value),
|
430
|
-
} }),
|
431
|
-
React.createElement("span", { className: 'suggestion-item--bgcolor'
|
432
|
-
+ (selectedItem ? ' suggestion-item--disabled' : ''), style: _this.props.getBackgroundColor
|
433
|
-
? {
|
434
|
-
backgroundColor: _this.props.getBackgroundColor(option.value),
|
435
|
-
color: (0, Label_1.getTextColor)(_this.props.getBackgroundColor(option.value)),
|
436
|
-
}
|
437
|
-
: undefined }, _this.props.optionTemplate
|
438
|
-
? _this.props.optionTemplate(option.value)
|
439
|
-
: _this.props.getLabel(option.value)),
|
440
|
-
option.children
|
441
|
-
&& React.createElement("span", { className: "suggestion-item__icon" },
|
442
|
-
React.createElement(Icon_1.Icon, { name: "chevron-right-thin" })))));
|
414
|
+
return (React.createElement(TreeSelectItem_1.TreeSelectItem, { key: i, option: option, handleTree: _this.handleTree, selectedItem: selectedItem, allowMultiple: _this.props.allowMultiple, getBorderColor: _this.props.getBorderColor, getBackgroundColor: _this.props.getBackgroundColor, getId: _this.props.getId, optionTemplate: _this.props.optionTemplate, getLabel: _this.props.getLabel, onClick: function () { return _this.setState({
|
415
|
+
searchFieldValue: '',
|
416
|
+
}); } }));
|
443
417
|
});
|
444
418
|
}
|
445
419
|
}
|
@@ -448,13 +422,12 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
448
422
|
var selectedItem = _this.state.value.some(function (obj) {
|
449
423
|
return _this.props.getId(obj) === _this.props.getId(item.value);
|
450
424
|
});
|
451
|
-
return (React.createElement("li", { key: i, className:
|
425
|
+
return (React.createElement("li", { key: i, className: 'suggestion-item suggestion-item--multi-select', onClick: function (event) {
|
452
426
|
_this.handleValue(event, item);
|
453
427
|
} },
|
454
428
|
React.createElement("button", { className: "suggestion-item--btn" }, _this.props.optionTemplate
|
455
429
|
? _this.props.optionTemplate(item.value)
|
456
|
-
: React.createElement("span", { className: selectedItem
|
457
|
-
? 'suggestion-item--disabled' : undefined }, _this.props.getLabel(item.value)))));
|
430
|
+
: (React.createElement("span", { className: selectedItem ? 'suggestion-item--disabled' : undefined }, _this.props.getLabel(item.value))))));
|
458
431
|
});
|
459
432
|
}
|
460
433
|
else {
|
@@ -486,11 +459,10 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
486
459
|
return _this.props.getId(obj) === _this.props.getId(buttonValue.value);
|
487
460
|
});
|
488
461
|
if (!selectedButton) {
|
489
|
-
return React.createElement("button", { className: 'autocomplete__button
|
462
|
+
return (React.createElement("button", { className: 'autocomplete__button autocomplete__button--multi-select', ref: this.categoryButtonRef, onMouseOver: function () { return _this.setState({ buttonMouseEvent: true }); }, onMouseOut: function () { return _this.setState({ buttonMouseEvent: false }); }, onClick: function (event) { return _this.handleBranchValue(event, buttonValue); } }, "Choose entire category"));
|
490
463
|
}
|
491
464
|
else {
|
492
|
-
return React.createElement("button", { className: 'autocomplete__button'
|
493
|
-
+ (this.props.selectBranchWithChildren ? ' autocomplete__button--multi-select' : '') + ' autocomplete__button--disabled' }, "Category selected");
|
465
|
+
return (React.createElement("button", { className: 'autocomplete__button autocomplete__button--multi-select autocomplete__button--disabled' }, "Category selected"));
|
494
466
|
}
|
495
467
|
};
|
496
468
|
TreeSelect.prototype.handleDebounce = function () {
|
@@ -523,11 +495,12 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
523
495
|
}, items: this.state.value, valueTemplate: this.props.valueTemplate, getLabel: this.props.getLabel }));
|
524
496
|
}
|
525
497
|
return (React.createElement(Form_1.InputWrapper, { label: this.props.label, error: this.props.error, required: this.props.required, disabled: this.props.disabled, info: this.props.info, inlineLabel: this.props.inlineLabel, labelHidden: this.props.labelHidden, htmlId: this.htmlId, tabindex: this.props.tabindex },
|
526
|
-
React.createElement("div", { className: "tags-input sd-input__input tags-input--".concat(this.props.allowMultiple ? 'multi-select' : 'single-select') },
|
498
|
+
React.createElement("div", { className: "tags-input sd-input__input tags-input--".concat(this.props.allowMultiple ? 'multi-select' : 'single-select'), ref: this.treeSelectRef },
|
527
499
|
this.props.allowMultiple
|
528
500
|
? React.createElement("div", { className: "tags-input__tags" },
|
529
501
|
this.props.readOnly
|
530
|
-
|| React.createElement("button", { ref: this.openDropdownRef, className: "tags-input__add-button ".concat(this.props.disabled ? 'tags-input__add-button--disabled' : ''), onClick: function () {
|
502
|
+
|| React.createElement("button", { ref: this.openDropdownRef, className: "tags-input__add-button ".concat(this.props.disabled ? 'tags-input__add-button--disabled' : ''), onClick: function (e) {
|
503
|
+
e.stopPropagation();
|
531
504
|
if (!_this.props.disabled) {
|
532
505
|
_this.setState({ openDropdown: !_this.state.openDropdown });
|
533
506
|
}
|
@@ -536,35 +509,26 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
536
509
|
React.createElement("ul", { className: "tags-input__tag-list" }, this.state.value.map(function (item, i) {
|
537
510
|
var Wrapper = function (_a) {
|
538
511
|
var backgroundColor = _a.backgroundColor, children = _a.children;
|
539
|
-
return (React.createElement(
|
540
|
-
+ (_this.props.readOnly ? ' tags-input__tag-item--readonly' : ''), onClick: function () { return (!_this.props.readOnly && !_this.props.disabled)
|
541
|
-
&& _this.removeClick(i); }, style: _this.props.valueTemplate
|
542
|
-
? { backgroundColor: backgroundColor }
|
543
|
-
: _this.props.getBackgroundColor
|
544
|
-
&& { backgroundColor: _this.props.getBackgroundColor(item) } },
|
545
|
-
React.createElement("span", { className: "tags-input__helper-box", style: { color: backgroundColor
|
546
|
-
? (0, Label_1.getTextColor)(backgroundColor)
|
547
|
-
: _this.props.getBackgroundColor
|
548
|
-
&& (0, Label_1.getTextColor)(_this.props.getBackgroundColor(item)),
|
549
|
-
} },
|
550
|
-
children,
|
551
|
-
!_this.props.readOnly
|
552
|
-
&& React.createElement("span", { className: "tags-input__remove-button" },
|
553
|
-
React.createElement(Icon_1.Icon, { name: "close-small" })))));
|
512
|
+
return (React.createElement(TreeSelectPill_1.TreeSelectPill, { item: item, readOnly: _this.props.readOnly, disabled: _this.props.disabled, valueTemplate: _this.props.valueTemplate, backgroundColor: backgroundColor, onRemove: function () { return _this.removeClick(i); }, getBackgroundColor: _this.props.getBackgroundColor }, children));
|
554
513
|
};
|
555
514
|
return (React.createElement(React.Fragment, { key: i }, _this.props.valueTemplate
|
556
515
|
? _this.props.valueTemplate(item, Wrapper)
|
557
|
-
: React.createElement(Wrapper, null,
|
558
|
-
React.createElement("span", null, _this.props.getLabel(item)))));
|
516
|
+
: (React.createElement(Wrapper, null,
|
517
|
+
React.createElement("span", null, _this.props.getLabel(item))))));
|
559
518
|
})),
|
560
519
|
this.state.value.length > 0
|
561
520
|
? (this.props.readOnly || this.props.disabled)
|
562
|
-
|| React.createElement("button", { className: "tags-input__remove-value", style: { position: 'relative', bottom: '2px' }, onClick: function () {
|
521
|
+
|| React.createElement("button", { className: "tags-input__remove-value", style: { position: 'relative', bottom: '2px' }, onClick: function (e) {
|
522
|
+
e.stopPropagation();
|
523
|
+
_this.setState({ value: [] });
|
524
|
+
} },
|
563
525
|
React.createElement(Icon_1.Icon, { name: 'remove-sign' }))
|
564
526
|
: null)
|
565
527
|
: React.createElement("div", { className: "tags-input__tags" },
|
566
528
|
this.props.readOnly
|
567
|
-
|| React.createElement("button", { className: "tags-input__overlay-button", ref: this.openDropdownRef, onClick: function () {
|
529
|
+
|| React.createElement("button", { className: "tags-input__overlay-button", ref: this.openDropdownRef, onClick: function () {
|
530
|
+
_this.setState({ openDropdown: !_this.state.openDropdown });
|
531
|
+
} }),
|
568
532
|
this.state.value.length < 1
|
569
533
|
&& React.createElement("span", { className: 'tags-input__single-item'
|
570
534
|
+ (this.props.readOnly ? ' tags-input__tag-item--readonly' : '') },
|
@@ -578,7 +542,7 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
578
542
|
&& React.createElement("div", { className: "item-border item-border-selected", style: borderColor
|
579
543
|
? { backgroundColor: borderColor }
|
580
544
|
: { backgroundColor: _this.props.getBorderColor(item) } }),
|
581
|
-
React.createElement("span", { style: { color: backgroundColor && (0, Label_1.getTextColor)(backgroundColor) }
|
545
|
+
React.createElement("span", { className: "tags-input__helper-box", style: { color: backgroundColor && (0, Label_1.getTextColor)(backgroundColor) } },
|
582
546
|
React.createElement("span", { className: backgroundColor && "tags-input__tag-item", style: { backgroundColor: backgroundColor, margin: 0 } }, children),
|
583
547
|
_this.props.readOnly
|
584
548
|
|| React.createElement("span", { className: "tags-input__remove-button" },
|
@@ -586,15 +550,14 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
586
550
|
};
|
587
551
|
return React.createElement(React.Fragment, { key: i }, _this.props.valueTemplate
|
588
552
|
? _this.props.valueTemplate(item, Wrapper)
|
589
|
-
: React.createElement(Wrapper, null,
|
590
|
-
React.createElement("span", null, _this.props.getLabel(item))));
|
553
|
+
: (React.createElement(Wrapper, null,
|
554
|
+
React.createElement("span", null, _this.props.getLabel(item)))));
|
591
555
|
})),
|
592
556
|
this.state.openDropdown
|
593
557
|
&& React.createElement("div", { className: "autocomplete autocomplete--multi-select"
|
594
558
|
+ (this.props.width === 'medium' ? ' autocomplete--fixed-width' : ''), style: { zIndex: this.props.zIndex }, ref: this.dropdownRef },
|
595
559
|
React.createElement("div", { className: 'autocomplete__header' },
|
596
560
|
React.createElement("div", { className: "autocomplete__icon", onClick: function () {
|
597
|
-
_this.backButtonValue();
|
598
561
|
_this.backButton();
|
599
562
|
} },
|
600
563
|
React.createElement(Icon_1.Icon, { name: "search", className: "search" })),
|
@@ -620,7 +583,6 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
620
583
|
(this.state.activeTree.length > 0 && this.state.buttonValue != null)
|
621
584
|
&& React.createElement("div", { className: 'autocomplete__category-header' },
|
622
585
|
React.createElement("div", { className: "autocomplete__icon", onClick: function () {
|
623
|
-
_this.backButtonValue();
|
624
586
|
_this.backButton();
|
625
587
|
} },
|
626
588
|
React.createElement(Icon_1.Icon, { name: "arrow-left", className: "arrow-left" })),
|
@@ -639,40 +601,16 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
639
601
|
var selectedItem = _this.state.value.some(function (obj) {
|
640
602
|
return _this.props.getId(obj) === _this.props.getId(option.value);
|
641
603
|
});
|
642
|
-
return (React.createElement(
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
} }
|
647
|
-
React.createElement("button", { className: "suggestion-item--btn ".concat(_this.props.getId(option.value), "-focus"), onKeyDown: function (event) {
|
648
|
-
if (event.key === 'Enter' && option.children) {
|
649
|
-
_this.setState({
|
650
|
-
buttonTarget: __spreadArray(__spreadArray([], _this.state.buttonTarget, true), [
|
651
|
-
_this.props.getId(option.value),
|
652
|
-
], false),
|
653
|
-
});
|
654
|
-
}
|
655
|
-
} },
|
656
|
-
(_this.props.getBorderColor && !_this.props.allowMultiple)
|
657
|
-
&& React.createElement("div", { className: "item-border", style: {
|
658
|
-
backgroundColor: _this.props.getBorderColor(option.value),
|
659
|
-
} }),
|
660
|
-
React.createElement("span", { className: 'suggestion-item--bgcolor'
|
661
|
-
+ (selectedItem ? ' suggestion-item--disabled' : ''), style: (_this.props.getBackgroundColor && option.value)
|
662
|
-
? {
|
663
|
-
backgroundColor: _this.props.getBackgroundColor(option.value),
|
664
|
-
color: (0, Label_1.getTextColor)(_this.props.getBackgroundColor(option.value)),
|
665
|
-
}
|
666
|
-
: undefined }, _this.props.optionTemplate
|
667
|
-
? _this.props.optionTemplate(option.value)
|
668
|
-
: _this.props.getLabel(option.value)),
|
669
|
-
option.children
|
670
|
-
&& React.createElement("span", { className: "suggestion-item__icon" },
|
671
|
-
React.createElement(Icon_1.Icon, { name: "chevron-right-thin" })))));
|
604
|
+
return (React.createElement(TreeSelectItem_1.TreeSelectItem, { key: i, option: option, handleTree: _this.handleTree, selectedItem: selectedItem, allowMultiple: _this.props.allowMultiple, getBorderColor: _this.props.getBorderColor, getBackgroundColor: _this.props.getBackgroundColor, getId: _this.props.getId, optionTemplate: _this.props.optionTemplate, getLabel: _this.props.getLabel, onKeyDown: function () { return _this.setState({
|
605
|
+
buttonTarget: __spreadArray(__spreadArray([], _this.state.buttonTarget, true), [
|
606
|
+
_this.props.getId(option.value),
|
607
|
+
], false),
|
608
|
+
}); } }));
|
672
609
|
}))
|
673
610
|
: null
|
674
611
|
: React.createElement("ul", { className: "suggestion-list suggestion-list--multi-select", ref: this.ref }, this.filteredItem(this.props.singleLevelSearch
|
675
|
-
? this.state.options
|
612
|
+
? this.state.options
|
613
|
+
: this.state.filterArr))))));
|
676
614
|
};
|
677
615
|
return TreeSelect;
|
678
616
|
}(React.Component));
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import { ITreeNode } from './TreeSelect';
|
3
|
+
export declare function getPrefixedItemId(id: string): string;
|
4
|
+
interface IProps<T> {
|
5
|
+
option: ITreeNode<T>;
|
6
|
+
selectedItem: boolean;
|
7
|
+
allowMultiple?: boolean;
|
8
|
+
handleTree(event: React.MouseEvent<HTMLLIElement, MouseEvent>, option: ITreeNode<T>): any;
|
9
|
+
getLabel(item: T): string;
|
10
|
+
getId(item: T): string;
|
11
|
+
getBackgroundColor?(item: T): string;
|
12
|
+
getBorderColor?(item: T): string;
|
13
|
+
optionTemplate?(item: T): React.ComponentType<T> | JSX.Element;
|
14
|
+
onClick?: () => void;
|
15
|
+
onKeyDown?: () => void;
|
16
|
+
}
|
17
|
+
export declare class TreeSelectItem<T> extends React.Component<IProps<T>> {
|
18
|
+
render(): JSX.Element;
|
19
|
+
}
|
20
|
+
export {};
|