superdesk-ui-framework 3.1.3 → 3.1.5

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.
Files changed (32) hide show
  1. package/app/fonts/sd_big-icons.eot +0 -0
  2. package/app/fonts/sd_big-icons.svg +11 -0
  3. package/app/fonts/sd_big-icons.ttf +0 -0
  4. package/app/fonts/sd_big-icons.woff +0 -0
  5. package/app/styles/_sd-tag-input.scss +1 -1
  6. package/app-typescript/components/TreeSelect/TreeSelect.tsx +118 -38
  7. package/app-typescript/components/TreeSelect/TreeSelectPill.tsx +20 -9
  8. package/app-typescript/components/avatar/avatar-group.tsx +1 -1
  9. package/app-typescript/index.ts +1 -1
  10. package/dist/examples.bundle.js +99931 -63624
  11. package/dist/playgrounds/react-playgrounds/Multiedit.tsx +1 -1
  12. package/dist/react/TreeSelect.tsx +61 -3
  13. package/dist/sd_big-icons.eot +0 -0
  14. package/dist/sd_big-icons.svg +11 -0
  15. package/dist/sd_big-icons.ttf +0 -0
  16. package/dist/sd_big-icons.woff +0 -0
  17. package/dist/superdesk-ui.bundle.css +1 -1
  18. package/dist/superdesk-ui.bundle.js +100086 -63789
  19. package/dist/vendor.bundle.js +55 -55
  20. package/examples/pages/playgrounds/react-playgrounds/Multiedit.tsx +1 -1
  21. package/examples/pages/react/TreeSelect.tsx +61 -3
  22. package/package.json +2 -1
  23. package/react/components/TreeSelect/TreeSelect.d.ts +5 -0
  24. package/react/components/TreeSelect/TreeSelect.js +80 -17
  25. package/react/components/TreeSelect/TreeSelectPill.d.ts +1 -0
  26. package/react/components/TreeSelect/TreeSelectPill.js +13 -4
  27. package/react/components/avatar/avatar-group.js +2 -2
  28. package/react/index.d.ts +1 -1
  29. package/react/index.js +3 -3
  30. package/app-typescript/components/Spacer.tsx +0 -79
  31. package/react/components/Spacer.d.ts +0 -30
  32. package/react/components/Spacer.js +0 -86
@@ -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__, __WEBPACK_EXTERNAL_MODULE_8__) {
10
+ })(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_9__) {
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 = 576);
73
+ /******/ return __webpack_require__(__webpack_require__.s = 798);
74
74
  /******/ })
75
75
  /************************************************************************/
76
76
  /******/ ({
@@ -82,7 +82,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE_0__;
82
82
 
83
83
  /***/ }),
84
84
 
85
- /***/ 21:
85
+ /***/ 24:
86
86
  /***/ (function(module, exports, __webpack_require__) {
87
87
 
88
88
  /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
@@ -17296,11 +17296,11 @@ 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__(53)(module)))
17299
+ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(40), __webpack_require__(56)(module)))
17300
17300
 
17301
17301
  /***/ }),
17302
17302
 
17303
- /***/ 35:
17303
+ /***/ 40:
17304
17304
  /***/ (function(module, exports) {
17305
17305
 
17306
17306
  var g;
@@ -17328,7 +17328,36 @@ module.exports = g;
17328
17328
 
17329
17329
  /***/ }),
17330
17330
 
17331
- /***/ 44:
17331
+ /***/ 56:
17332
+ /***/ (function(module, exports) {
17333
+
17334
+ module.exports = function(module) {
17335
+ if(!module.webpackPolyfill) {
17336
+ module.deprecate = function() {};
17337
+ module.paths = [];
17338
+ // module.parent = undefined by default
17339
+ if(!module.children) module.children = [];
17340
+ Object.defineProperty(module, "loaded", {
17341
+ enumerable: true,
17342
+ get: function() {
17343
+ return module.l;
17344
+ }
17345
+ });
17346
+ Object.defineProperty(module, "id", {
17347
+ enumerable: true,
17348
+ get: function() {
17349
+ return module.i;
17350
+ }
17351
+ });
17352
+ module.webpackPolyfill = 1;
17353
+ }
17354
+ return module;
17355
+ };
17356
+
17357
+
17358
+ /***/ }),
17359
+
17360
+ /***/ 57:
17332
17361
  /***/ (function(module, exports, __webpack_require__) {
17333
17362
 
17334
17363
  var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
@@ -28217,58 +28246,29 @@ return jQuery;
28217
28246
 
28218
28247
  /***/ }),
28219
28248
 
28220
- /***/ 53:
28221
- /***/ (function(module, exports) {
28222
-
28223
- module.exports = function(module) {
28224
- if(!module.webpackPolyfill) {
28225
- module.deprecate = function() {};
28226
- module.paths = [];
28227
- // module.parent = undefined by default
28228
- if(!module.children) module.children = [];
28229
- Object.defineProperty(module, "loaded", {
28230
- enumerable: true,
28231
- get: function() {
28232
- return module.l;
28233
- }
28234
- });
28235
- Object.defineProperty(module, "id", {
28236
- enumerable: true,
28237
- get: function() {
28238
- return module.i;
28239
- }
28240
- });
28241
- module.webpackPolyfill = 1;
28242
- }
28243
- return module;
28244
- };
28245
-
28246
-
28247
- /***/ }),
28248
-
28249
- /***/ 576:
28249
+ /***/ 798:
28250
28250
  /***/ (function(module, exports, __webpack_require__) {
28251
28251
 
28252
28252
  "use strict";
28253
28253
 
28254
28254
 
28255
- __webpack_require__(21);
28255
+ __webpack_require__(24);
28256
28256
 
28257
- __webpack_require__(44);
28257
+ __webpack_require__(57);
28258
28258
 
28259
- __webpack_require__(577);
28259
+ __webpack_require__(799);
28260
28260
 
28261
- __webpack_require__(579);
28261
+ __webpack_require__(801);
28262
28262
 
28263
- __webpack_require__(581);
28263
+ __webpack_require__(803);
28264
28264
 
28265
28265
  __webpack_require__(0);
28266
28266
 
28267
- __webpack_require__(8);
28267
+ __webpack_require__(9);
28268
28268
 
28269
28269
  /***/ }),
28270
28270
 
28271
- /***/ 577:
28271
+ /***/ 799:
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__(44), __webpack_require__(578) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
28295
+ !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(57), __webpack_require__(800) ], __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
- /***/ 578:
29033
+ /***/ 800:
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__(44) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
29042
+ !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(57) ], __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
- /***/ 579:
29063
+ /***/ 801:
29064
29064
  /***/ (function(module, exports, __webpack_require__) {
29065
29065
 
29066
- __webpack_require__(580);
29066
+ __webpack_require__(802);
29067
29067
  module.exports = angular;
29068
29068
 
29069
29069
 
29070
29070
  /***/ }),
29071
29071
 
29072
- /***/ 580:
29072
+ /***/ 802:
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__(44)))
65675
+ /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(57)))
65676
65676
 
65677
65677
  /***/ }),
65678
65678
 
65679
- /***/ 581:
65679
+ /***/ 803:
65680
65680
  /***/ (function(module, exports, __webpack_require__) {
65681
65681
 
65682
- __webpack_require__(582);
65682
+ __webpack_require__(804);
65683
65683
  module.exports = 'ngAnimate';
65684
65684
 
65685
65685
 
65686
65686
  /***/ }),
65687
65687
 
65688
- /***/ 582:
65688
+ /***/ 804:
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
- /***/ 8:
69967
+ /***/ 9:
69968
69968
  /***/ (function(module, exports) {
69969
69969
 
69970
- module.exports = __WEBPACK_EXTERNAL_MODULE_8__;
69970
+ module.exports = __WEBPACK_EXTERNAL_MODULE_9__;
69971
69971
 
69972
69972
  /***/ })
69973
69973
 
@@ -4,7 +4,7 @@ import * as Layout from '../../../../app-typescript/components/Layouts';
4
4
  import * as Form from '../../../../app-typescript/components/Form';
5
5
  import * as Nav from '../../../../app-typescript/components/Navigation';
6
6
  import { BoxedList, BoxedListItem, BoxedListContentRow } from '../../../../app-typescript/components/Lists';
7
- import { Spacer } from '../../../../app-typescript/components/Spacer';
7
+ import { Spacer } from '@superdesk/common';
8
8
 
9
9
  interface IProps {
10
10
  children?: React.ReactNode;
@@ -252,7 +252,7 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
252
252
  label='TreeSelect Label'
253
253
  info='Info Message'
254
254
  searchPlaceholder='Search...'
255
- getBackgroundColor={(item: any) => item.bgColor}
255
+ getBackgroundColor={(item: any) => item.bgColor}
256
256
  valueTemplate={(item, Wrapper) => {
257
257
  return (
258
258
  <Wrapper backgroundColor={item.bgColor}>
@@ -278,7 +278,65 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
278
278
  label='TreeSelect Label'
279
279
  info='Info Message'
280
280
  searchPlaceholder='Search...'
281
- getBackgroundColor={(item: any) => item.bgColor}
281
+ getBackgroundColor={(item: any) => item.bgColor}
282
+ valueTemplate={(item, Wrapper) => {
283
+ return (
284
+ <Wrapper backgroundColor={item.bgColor}>
285
+ <span>{item.name}</span>
286
+ </Wrapper>
287
+ );
288
+ }}
289
+ onChange={(e) => false}
290
+ />
291
+ `}</Markup.ReactMarkupCode>
292
+
293
+ </Markup.ReactMarkup>
294
+
295
+ <p className='docs-page__paragraph'>Sortable mode in TreeSelect.</p>
296
+ <Markup.ReactMarkup>
297
+ <Markup.ReactMarkupPreview>
298
+ <div className='docs-page__content-row docs-page__content-row--no-margin'>
299
+ <div className='form__row'>
300
+ <TreeSelect
301
+ kind='synchronous'
302
+ value={[{name: 'Category1'}, {name: 'Category2'}, {name: 'Category3'}]}
303
+ getOptions={() => options}
304
+ getId={(item) => item.name}
305
+ getLabel={(item) => item.name}
306
+ selectBranchWithChildren
307
+ allowMultiple
308
+ sortable
309
+ label='TreeSelect Label'
310
+ info='Info Message'
311
+ searchPlaceholder='Search...'
312
+ getBackgroundColor={(item: any) => item.bgColor}
313
+ valueTemplate={(item, Wrapper) => {
314
+ return (
315
+ <Wrapper backgroundColor={item.bgColor}>
316
+ <span>{item.name}</span>
317
+ </Wrapper>
318
+ );
319
+ }}
320
+ onChange={(e) => false}
321
+ />
322
+ </div>
323
+ </div>
324
+ </Markup.ReactMarkupPreview>
325
+
326
+ <Markup.ReactMarkupCode>{`
327
+ <TreeSelect
328
+ kind='synchronous'
329
+ value={[{name: 'Category1'}]}
330
+ getOptions={() => options}
331
+ getId={(item) => item.name}
332
+ getLabel={(item) => item.name}
333
+ selectBranchWithChildren
334
+ allowMultiple
335
+ sortable
336
+ label='TreeSelect Label'
337
+ info='Info Message'
338
+ searchPlaceholder='Search...'
339
+ getBackgroundColor={(item: any) => item.bgColor}
282
340
  valueTemplate={(item, Wrapper) => {
283
341
  return (
284
342
  <Wrapper backgroundColor={item.bgColor}>
@@ -401,6 +459,7 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
401
459
  <Prop name='loading' isRequired={false} type='boolean' default='false' description='Adds a loading indicator in dropdown.'/>
402
460
  <Prop name='allowMultiple' isRequired={false} type='boolean' default='/' description='Enable multi-select mode.'/>
403
461
  <Prop name='singleLevelSearch' isRequired={false} type='boolean' default='/' description='Limit search to only the level that is displayed.'/>
462
+ <Prop name='sortable' isRequired={false} type='boolean' default='/' description='Enable drag & drop functionality.'/>
404
463
  <Prop name='placeholder' isRequired={false} type='string' default='/' description='Placeholder of component in single select mode.'/>
405
464
  <Prop name='searchPlaceholder' isRequired={false} type='string' default='/' description='Filter input placeholder.'/>
406
465
  <Prop name='getLabel' isRequired={true} type='Function' default='/' description='Callback to invoke when value changes.'/>
@@ -409,7 +468,6 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
409
468
  <Prop name='getBorderColor' isRequired={true} type='Function' default='/' description='Function to return border color of individual item in options in single-select mode.'/>
410
469
  <Prop name='valueTemplate' isRequired={false} type='Function(item, Wrapper)' default='/' description='Function that gets an item in the value and returns the content for it.'/>
411
470
  <Prop name='optionTemplate' isRequired={false} type='Function(item)' default='/' description='Function that gets the option and returns the content for it.'/>
412
- <Prop name='searchOptions' isRequired={false} type='Function' default='/' description='The function will be called when a search is initiated from UI in asynchronous mode.'/>
413
471
  <Prop name='onChange' isRequired={true} type='Function' default='/' description='Callback to invoke when value changes.'/>
414
472
  <Prop name='label' isRequired={false} type='string' default='/' description='Label of component.' />
415
473
  <Prop name='inlineLabel' isRequired={false} type='boolean' default='false' description='Position labels as inline.' />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "superdesk-ui-framework",
3
- "version": "3.1.3",
3
+ "version": "3.1.5",
4
4
  "license": "AGPL-3.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -92,6 +92,7 @@
92
92
  },
93
93
  "dependencies": {
94
94
  "@popperjs/core": "^2.4.0",
95
+ "@superdesk/common": "0.0.28",
95
96
  "@superdesk/primereact": "^5.0.2-12",
96
97
  "@superdesk/react-resizable-panels": "0.0.39",
97
98
  "@types/enzyme-adapter-react-16": "^1.0.6",
@@ -1,5 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { IInputWrapper } from '../Form/InputWrapper';
3
+ import { DropResult } from "react-beautiful-dnd";
3
4
  interface IState<T> {
4
5
  value: Array<T>;
5
6
  options: Array<ITreeNode<T>>;
@@ -25,7 +26,10 @@ interface IPropsBase<T> extends IInputWrapper {
25
26
  singleLevelSearch?: boolean;
26
27
  placeholder?: string;
27
28
  searchPlaceholder?: string;
29
+ noResultsFoundMessage?: string;
30
+ dropdownInitiallyOpen?: boolean;
28
31
  zIndex?: number;
32
+ sortable?: boolean;
29
33
  'data-test-id'?: string;
30
34
  getLabel(item: T): string;
31
35
  getId(item: T): string;
@@ -83,6 +87,7 @@ export declare class TreeSelect<T> extends React.Component<IProps<T>, IState<T>>
83
87
  private debounceFn;
84
88
  private ICancelFn;
85
89
  handleDebounce(): void;
90
+ onDragEnd(result: DropResult): void;
86
91
  render(): JSX.Element;
87
92
  }
88
93
  export {};
@@ -14,6 +14,17 @@ var __extends = (this && this.__extends) || (function () {
14
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
15
  };
16
16
  })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
17
28
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
29
  if (k2 === undefined) k2 = k;
19
30
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -65,6 +76,13 @@ var TreeSelectPill_1 = require("./TreeSelectPill");
65
76
  var TreeSelectItem_1 = require("./TreeSelectItem");
66
77
  var KeyboardNavigation_1 = require("./KeyboardNavigation");
67
78
  var WithPortal_1 = require("../WithPortal");
79
+ var react_beautiful_dnd_1 = require("react-beautiful-dnd");
80
+ var reorder = function (list, startIndex, endIndex) {
81
+ var result = Array.from(list);
82
+ var removed = result.splice(startIndex, 1)[0];
83
+ result.splice(endIndex, 0, removed);
84
+ return result;
85
+ };
68
86
  var TreeSelect = /** @class */ (function (_super) {
69
87
  __extends(TreeSelect, _super);
70
88
  function TreeSelect(props) {
@@ -120,6 +138,9 @@ var TreeSelect = /** @class */ (function (_super) {
120
138
  document.addEventListener("mousedown", _this.onMouseDown);
121
139
  document.addEventListener("keydown", _this.onKeyDown);
122
140
  document.addEventListener("keydown", _this.onPressEsc);
141
+ if (_this.props.dropdownInitiallyOpen) {
142
+ _this.setState({ openDropdown: true });
143
+ }
123
144
  };
124
145
  _this.debounceFn = (0, debounce_1.default)(_this.handleDebounce, 500);
125
146
  _this.state = {
@@ -155,6 +176,7 @@ var TreeSelect = /** @class */ (function (_super) {
155
176
  _this.openDropdownRef = React.createRef();
156
177
  _this.treeSelectRef = React.createRef();
157
178
  _this.popperInstance = null;
179
+ _this.onDragEnd = _this.onDragEnd.bind(_this);
158
180
  return _this;
159
181
  }
160
182
  TreeSelect.prototype.componentWillUnmount = function () {
@@ -398,6 +420,7 @@ var TreeSelect = /** @class */ (function (_super) {
398
420
  };
399
421
  TreeSelect.prototype.filteredItem = function (arr) {
400
422
  var _this = this;
423
+ var _a;
401
424
  if (this.props.kind === 'synchronous') {
402
425
  var filteredArr = arr.filter(function (item) {
403
426
  if (_this.state.searchFieldValue) {
@@ -429,17 +452,22 @@ var TreeSelect = /** @class */ (function (_super) {
429
452
  }
430
453
  }
431
454
  else if (this.props.kind === 'asynchronous') {
432
- return this.state.options.map(function (item, i) {
433
- var selectedItem = _this.state.value.some(function (obj) {
434
- return _this.props.getId(obj) === _this.props.getId(item.value);
455
+ if (this.state.options.length > 0) {
456
+ return this.state.options.map(function (item, i) {
457
+ var selectedItem = _this.state.value.some(function (obj) {
458
+ return _this.props.getId(obj) === _this.props.getId(item.value);
459
+ });
460
+ return (React.createElement("li", { key: i, className: 'suggestion-item suggestion-item--multi-select', onClick: function (event) {
461
+ _this.handleValue(event, item);
462
+ } },
463
+ React.createElement("button", { className: "suggestion-item--btn", "data-test-id": "option" }, _this.props.optionTemplate
464
+ ? _this.props.optionTemplate(item.value)
465
+ : (React.createElement("span", { className: selectedItem ? 'suggestion-item--selected' : undefined }, _this.props.getLabel(item.value))))));
435
466
  });
436
- return (React.createElement("li", { key: i, className: 'suggestion-item suggestion-item--multi-select', onClick: function (event) {
437
- _this.handleValue(event, item);
438
- } },
439
- React.createElement("button", { className: "suggestion-item--btn", "data-test-id": "option" }, _this.props.optionTemplate
440
- ? _this.props.optionTemplate(item.value)
441
- : (React.createElement("span", { className: selectedItem ? 'suggestion-item--selected' : undefined }, _this.props.getLabel(item.value))))));
442
- });
467
+ }
468
+ else {
469
+ return React.createElement("li", { className: "suggestion-item--nothing-found" }, (_a = this.props.noResultsFoundMessage) !== null && _a !== void 0 ? _a : 'Nothing found');
470
+ }
443
471
  }
444
472
  else {
445
473
  return;
@@ -481,17 +509,26 @@ var TreeSelect = /** @class */ (function (_super) {
481
509
  this.setState({ options: [] });
482
510
  if (this.props.kind === 'asynchronous') {
483
511
  if (this.state.searchFieldValue) {
484
- this.setState({
485
- loading: true,
486
- });
487
512
  this.ICancelFn = this.props.searchOptions(this.state.searchFieldValue, function (items) {
488
513
  var _a;
489
514
  _this.setState({ options: items, loading: false });
490
515
  (_a = _this.popperInstance) === null || _a === void 0 ? void 0 : _a.update();
491
516
  });
492
517
  }
518
+ else {
519
+ this.setState({ options: this.state.firstBranchOptions, loading: false });
520
+ }
493
521
  }
494
522
  };
523
+ TreeSelect.prototype.onDragEnd = function (result) {
524
+ if (!result.destination) {
525
+ return;
526
+ }
527
+ var value = reorder(this.state.value, result.source.index, result.destination.index);
528
+ this.setState({
529
+ value: value,
530
+ });
531
+ };
495
532
  TreeSelect.prototype.render = function () {
496
533
  var _this = this;
497
534
  var _a, _b;
@@ -506,6 +543,27 @@ var TreeSelect = /** @class */ (function (_super) {
506
543
  getBorderColor: this.props.getBorderColor,
507
544
  }, items: this.state.value, valueTemplate: this.props.valueTemplate, getLabel: this.props.getLabel }));
508
545
  }
546
+ var ListWrapper = this.props.sortable
547
+ ? function (_a) {
548
+ var children = _a.children;
549
+ return (React.createElement(react_beautiful_dnd_1.DragDropContext, { onDragEnd: _this.onDragEnd },
550
+ React.createElement(react_beautiful_dnd_1.Droppable, { droppableId: "droppable", direction: "horizontal" }, function (provided, _snapshot) { return (React.createElement("ul", __assign({ className: "tags-input__tag-list", ref: provided.innerRef }, provided.droppableProps),
551
+ children,
552
+ provided.placeholder)); })));
553
+ }
554
+ : function (_a) {
555
+ var children = _a.children;
556
+ return React.createElement("ul", { className: "tags-input__tag-list" }, children);
557
+ };
558
+ var ItemWrapper = this.props.sortable
559
+ ? function (_a) {
560
+ var children = _a.children, itemId = _a.itemId, i = _a.i;
561
+ return (React.createElement(react_beautiful_dnd_1.Draggable, { draggableId: itemId, index: i }, function (provided2) { return (React.createElement("div", __assign({ ref: provided2.innerRef }, provided2.draggableProps, provided2.dragHandleProps), children)); }));
562
+ }
563
+ : function (_a) {
564
+ var children = _a.children;
565
+ return React.createElement(React.Fragment, null, children);
566
+ };
509
567
  return (React.createElement(Form_1.InputWrapper, { label: this.props.label, error: this.props.error, invalid: this.props.error != null, 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, fullWidth: (_a = this.props.inputWidth === '100%') !== null && _a !== void 0 ? _a : false, "data-test-id": this.props['data-test-id'] },
510
568
  React.createElement("div", { className: "\n tags-input sd-input__input\n tags-input--".concat(this.props.allowMultiple ? 'multi-select' : 'single-select'), ref: this.treeSelectRef, "data-test-id": this.props.allowMultiple ? undefined : 'open-popover' }, this.props.allowMultiple
511
569
  ? React.createElement("div", { className: "tags-input__tags" },
@@ -520,12 +578,13 @@ var TreeSelect = /** @class */ (function (_super) {
520
578
  }
521
579
  }, "data-test-id": "open-popover" },
522
580
  React.createElement("i", { className: "icon-plus-large" })),
523
- React.createElement("ul", { className: "tags-input__tag-list" }, this.state.value.map(function (item, i) {
581
+ React.createElement(ListWrapper, null, this.state.value.map(function (item, i) {
524
582
  var Wrapper = function (_a) {
525
583
  var backgroundColor = _a.backgroundColor, children = _a.children;
526
- 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));
584
+ 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, draggable: _this.props.sortable }, children));
527
585
  };
528
- return (React.createElement(React.Fragment, { key: i }, _this.props.valueTemplate
586
+ var itemId = _this.props.getId(item);
587
+ return (React.createElement(ItemWrapper, { itemId: itemId, key: itemId, i: i }, _this.props.valueTemplate
529
588
  ? _this.props.valueTemplate(item, Wrapper)
530
589
  : (React.createElement(Wrapper, null,
531
590
  React.createElement("span", null, _this.props.getLabel(item))))));
@@ -588,7 +647,11 @@ var TreeSelect = /** @class */ (function (_super) {
588
647
  if (_this.ICancelFn) {
589
648
  _this.ICancelFn();
590
649
  }
591
- _this.setState({ searchFieldValue: event.target.value, options: [] });
650
+ _this.setState({
651
+ searchFieldValue: event.target.value,
652
+ options: [],
653
+ loading: true,
654
+ });
592
655
  (_b = _this.popperInstance) === null || _b === void 0 ? void 0 : _b.update();
593
656
  _this.debounceFn();
594
657
  }
@@ -7,6 +7,7 @@ interface IProps<T> {
7
7
  onRemove(): void;
8
8
  valueTemplate?(item: T, Wrapper: React.ElementType): React.ComponentType<T> | JSX.Element;
9
9
  getBackgroundColor?(item: T): string;
10
+ draggable?: boolean;
10
11
  }
11
12
  export declare class TreeSelectPill<T> extends React.Component<IProps<T>> {
12
13
  render(): JSX.Element;
@@ -37,9 +37,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
37
37
  __setModuleDefault(result, mod);
38
38
  return result;
39
39
  };
40
+ var __importDefault = (this && this.__importDefault) || function (mod) {
41
+ return (mod && mod.__esModule) ? mod : { "default": mod };
42
+ };
40
43
  Object.defineProperty(exports, "__esModule", { value: true });
41
44
  exports.TreeSelectPill = void 0;
45
+ var classnames_1 = __importDefault(require("classnames"));
42
46
  var React = __importStar(require("react"));
47
+ var DragHandle_1 = require("../DragHandle");
43
48
  var Icon_1 = require("../Icon");
44
49
  var Label_1 = require("../Label");
45
50
  var TreeSelectPill = /** @class */ (function (_super) {
@@ -49,12 +54,15 @@ var TreeSelectPill = /** @class */ (function (_super) {
49
54
  }
50
55
  TreeSelectPill.prototype.render = function () {
51
56
  var _this = this;
52
- return (React.createElement("li", { className: "tags-input__tag-item tags-input__tag-item--multi-select"
53
- + (this.props.readOnly ? ' tags-input__tag-item--readonly' : ''), onClick: function () { return (!_this.props.readOnly && !_this.props.disabled)
54
- && _this.props.onRemove(); }, style: this.props.valueTemplate
57
+ var classes = (0, classnames_1.default)('tags-input__tag-item tags-input__tag-item--multi-select', {
58
+ 'tags-input__tag-item--readonly': this.props.readOnly,
59
+ 'tags-input__tag-item--draggable': this.props.draggable,
60
+ });
61
+ return (React.createElement("li", { className: classes, style: this.props.valueTemplate
55
62
  ? { backgroundColor: this.props.backgroundColor }
56
63
  : this.props.getBackgroundColor
57
64
  && { backgroundColor: this.props.getBackgroundColor(this.props.item) }, "data-test-id": "item" },
65
+ this.props.draggable && (React.createElement(DragHandle_1.DragHandle, { blank: true, dotsInRow: '3', dotRows: '4' })),
58
66
  React.createElement("span", { className: "tags-input__helper-box", style: {
59
67
  color: this.props.backgroundColor
60
68
  ? (0, Label_1.getTextColor)(this.props.backgroundColor)
@@ -63,7 +71,8 @@ var TreeSelectPill = /** @class */ (function (_super) {
63
71
  } },
64
72
  this.props.children,
65
73
  !this.props.readOnly
66
- && React.createElement("span", { className: "tags-input__remove-button", "data-test-id": "remove" },
74
+ && React.createElement("button", { className: "tags-input__remove-button", "data-test-id": "remove", onClick: function () { return (!_this.props.readOnly && !_this.props.disabled)
75
+ && _this.props.onRemove(); } },
67
76
  React.createElement(Icon_1.Icon, { name: "close-small" })))));
68
77
  };
69
78
  return TreeSelectPill;
@@ -59,7 +59,7 @@ var avatar_1 = require("./avatar");
59
59
  var avatar_wrapper_1 = require("./avatar-wrapper");
60
60
  var avatar_number_1 = require("./avatar-number");
61
61
  var avatar_placeholder_1 = require("./avatar-placeholder");
62
- var Spacer_1 = require("../Spacer");
62
+ var common_1 = require("@superdesk/common");
63
63
  var WithPopover_1 = require("../WithPopover");
64
64
  function isAvatar(item) {
65
65
  return item['kind'] == null;
@@ -106,7 +106,7 @@ var AvatarGroup = /** @class */ (function (_super) {
106
106
  var someHaveDisplayName = this.props.items.some(function (item) { return isAvatar(item) && item.displayName.length > 0; });
107
107
  return (React.createElement(WithPopover_1.WithPopover, { zIndex: (_a = this.props.zIndex) !== null && _a !== void 0 ? _a : 101, placement: 'bottom-end', component: function () { return (React.createElement("div", { className: "avatar-popup" }, _this.props.items.map(function (item, index) {
108
108
  return (someHaveDisplayName
109
- ? React.createElement(Spacer_1.Spacer, { h: true, alignItems: 'center', gap: '16', noGrow: true, key: index },
109
+ ? React.createElement(common_1.Spacer, { h: true, alignItems: 'center', gap: '16', noGrow: true, key: index },
110
110
  isAvatar(item)
111
111
  && item.displayName,
112
112
  isAvatar(item)
package/react/index.d.ts CHANGED
@@ -91,7 +91,7 @@ export { ContentListItem } from './components/Lists/ContentList';
91
91
  export { MultiSelect } from './components/MultiSelect';
92
92
  export { ResizablePanels } from './components/ResizablePanels';
93
93
  export { WithPopover } from './components/WithPopover';
94
- export { Spacer, SpacerBlock } from './components/Spacer';
94
+ export { Spacer, SpacerBlock } from '@superdesk/common';
95
95
  export { ResizeObserverComponent } from './components/ResizeObserverComponent';
96
96
  export { DragHandleDots } from './components/DragHandleDots';
97
97
  export { DragHandle } from './components/DragHandle';
package/react/index.js CHANGED
@@ -220,9 +220,9 @@ var ResizablePanels_1 = require("./components/ResizablePanels");
220
220
  Object.defineProperty(exports, "ResizablePanels", { enumerable: true, get: function () { return ResizablePanels_1.ResizablePanels; } });
221
221
  var WithPopover_1 = require("./components/WithPopover");
222
222
  Object.defineProperty(exports, "WithPopover", { enumerable: true, get: function () { return WithPopover_1.WithPopover; } });
223
- var Spacer_1 = require("./components/Spacer");
224
- Object.defineProperty(exports, "Spacer", { enumerable: true, get: function () { return Spacer_1.Spacer; } });
225
- Object.defineProperty(exports, "SpacerBlock", { enumerable: true, get: function () { return Spacer_1.SpacerBlock; } });
223
+ var common_1 = require("@superdesk/common");
224
+ Object.defineProperty(exports, "Spacer", { enumerable: true, get: function () { return common_1.Spacer; } });
225
+ Object.defineProperty(exports, "SpacerBlock", { enumerable: true, get: function () { return common_1.SpacerBlock; } });
226
226
  var ResizeObserverComponent_1 = require("./components/ResizeObserverComponent");
227
227
  Object.defineProperty(exports, "ResizeObserverComponent", { enumerable: true, get: function () { return ResizeObserverComponent_1.ResizeObserverComponent; } });
228
228
  var DragHandleDots_1 = require("./components/DragHandleDots");