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
Binary file
@@ -7,6 +7,16 @@
7
7
  <font-face units-per-em="1024" ascent="960" descent="-64" />
8
8
  <missing-glyph horiz-adv-x="1024" />
9
9
  <glyph unicode="&#x20;" horiz-adv-x="512" d="" />
10
+ <<<<<<< HEAD
11
+ <glyph unicode="&#xe600;" glyph-name="dashboard" d="M275.692 78.769h157.538v236.308h157.538v-236.308h157.538v315.077h157.538l-362.575 381.44c-7.632 7.626-18.172 12.342-29.814 12.342s-22.182-4.716-29.814-12.343v0l-365.489-381.44h157.538v-315.077z" />
12
+ <glyph unicode="&#xe601;" glyph-name="view" d="M512 787.693c-310.863 0-512-354.462-512-354.462s197.474-354.462 512-354.462c292.588 0 512 354.462 512 354.462s-215.788 354.462-512 354.462zM512 196.923c-130.509 0-236.308 105.799-236.308 236.308s105.799 236.308 236.308 236.308c130.509 0 236.308-105.799 236.308-236.308v0c0-130.509-105.799-236.308-236.308-236.308v0zM630.154 433.231c0-65.255-52.899-118.154-118.154-118.154s-118.154 52.899-118.154 118.154c0 65.255 52.899 118.154 118.154 118.154s118.154-52.899 118.154-118.154z" />
13
+ <glyph unicode="&#xe602;" glyph-name="tasks" d="M748.308 787.693v-78.769h-157.538v78.769h-157.538v-78.769h-157.538v78.769h-118.154c-0.297 0.008-0.647 0.013-0.998 0.013-20.504 0-37.192-16.339-37.755-36.707l-0.001-0.052q0-0.985 0-2.009v-672.571c-0.017-0.407-0.026-0.884-0.026-1.363 0-19.223 15.218-34.892 34.264-35.617l0.066-0.002h713.098c0.52-0.026 1.13-0.040 1.743-0.040 20.138 0 36.587 15.793 37.638 35.669l0.004 0.094q0 1.221 0 2.442v673.201c0.021 0.454 0.033 0.987 0.033 1.522 0 19.103-15.112 34.677-34.033 35.419l-0.067 0.002h-123.195zM787.692 157.539h-551.385v472.615h551.385v-472.615zM344.734 866.462h19.456c16.379 0 29.657-13.278 29.657-29.657v-58.841c0-16.379-13.278-29.657-29.657-29.657h-19.456c-16.379 0-29.657 13.278-29.657 29.657v58.841c0 16.379 13.278 29.657 29.657 29.657zM659.81 866.462h19.456c16.379 0 29.657-13.278 29.657-29.657v-58.841c0-16.379-13.278-29.657-29.657-29.657h-19.456c-16.379 0-29.657 13.278-29.657 29.657v58.841c0 16.379 13.278 29.657 29.657 29.657zM433.231 315.077l-77.942 90.585-40.212-41.118 118.154-128.236 275.692 274.747-39.385 40.33z" />
14
+ <glyph unicode="&#xe603;" glyph-name="calendar" d="M787.692 787.693v-78.769h-157.538v78.769h-236.308v-78.769h-157.538v78.769h-118.784c-0.297 0.008-0.647 0.013-0.998 0.013-20.86 0-37.77-16.91-37.77-37.77 0-0.351 0.005-0.701 0.014-1.049l-0.001 0.051v-672.61c-0.015-0.388-0.024-0.843-0.024-1.3 0-19.624 15.859-35.544 35.461-35.643h791.403c0.577-0.032 1.253-0.050 1.933-0.050 20.816 0 37.691 16.875 37.691 37.691 0 0.184-0.001 0.367-0.004 0.55v-0.028 673.201c0.015 0.388 0.024 0.843 0.024 1.3 0 19.624-15.859 35.544-35.461 35.643h-122.101zM866.462 118.154h-708.923v472.615h708.923v-472.615zM319.37 748.308h-8.586c-19.372 0.022-35.069 15.72-35.092 35.090v47.972c0.067 19.395 15.805 35.092 35.21 35.092 0.083 0 0.166 0 0.249-0.001h8.612c19.206-0.2 34.698-15.816 34.698-35.051 0-0.014 0-0.029 0-0.043v0.002-48.010c-0.089-19.378-15.819-35.053-35.209-35.053-0.083 0-0.166 0-0.249 0.001h0.367zM713.216 748.308h-8.625c-19.355 0.045-35.030 15.734-35.052 35.090v47.972c0.067 19.395 15.805 35.092 35.21 35.092 0.083 0 0.166 0 0.249-0.001h8.612c19.206-0.2 34.698-15.816 34.698-35.051 0-0.014 0-0.029 0-0.043v0.002-48.010c-0.089-19.378-15.819-35.053-35.209-35.053-0.083 0-0.166 0-0.249 0.001h0.367zM236.308 512h196.923v-196.923h-196.923v196.923z" />
15
+ <glyph unicode="&#xe604;" glyph-name="marked-star" d="M512 827.077l107.087-266.398 286.759-19.417-220.554-184.084 70.105-278.41-243.397 152.655-243.397-152.655 70.105 278.41-220.554 184.084 286.759 19.417 107.087 266.398z" />
16
+ <glyph unicode="&#xe605;" glyph-name="archive" d="M787.692 748.308h-551.385v-275.692h551.385v275.692zM590.769 590.769h-157.538v39.385h157.538v-39.385zM787.692 433.231h-551.385v-275.692h551.385v275.692zM590.769 275.693h-157.538v39.385h157.538v-39.385zM866.462 866.462h-708.923c-21.752 0-39.385-17.633-39.385-39.385v0-748.308c0-21.752 17.633-39.385 39.385-39.385v0h708.923c21.752 0 39.385 17.633 39.385 39.385v0 748.308c0 21.752-17.633 39.385-39.385 39.385v0zM827.077 748.308v-630.154h-630.154v669.538h630.154v-39.385zM236.308 39.385h157.538v-39.385h-157.538v39.385zM630.154 39.385h157.538v-39.385h-157.538v39.385z" />
17
+ <glyph unicode="&#xe606;" glyph-name="spike" d="M236.308 630.154v-512c0.134-43.449 35.32-78.635 78.756-78.769h393.859c43.449 0.134 78.635 35.32 78.769 78.756v512.013h-551.385zM393.846 118.154h-78.769v433.231h78.769v-433.231zM551.385 118.154h-78.769v433.231h78.769v-433.231zM708.923 118.154h-78.769v433.231h78.769v-433.231zM787.692 748.308h-165.415c-16.187 46.218-59.431 78.769-110.277 78.769s-94.089-32.552-110.027-77.952l-0.25-0.817h-165.415c-0.668 0.043-1.448 0.067-2.233 0.067-20.555 0-37.218-16.663-37.218-37.218 0-0.786 0.024-1.566 0.072-2.339l-0.005 0.106v-39.385h630.154v39.385c0.043 0.668 0.067 1.448 0.067 2.233 0 20.555-16.663 37.218-37.218 37.218-0.786 0-1.566-0.024-2.339-0.072l0.106 0.005z" />
18
+ <glyph unicode="&#xe607;" glyph-name="unspike" d="M787.692 748.308h-165.415c-16.187 46.218-59.431 78.769-110.277 78.769s-94.089-32.552-110.027-77.952l-0.25-0.817h-165.415c-0.668 0.043-1.448 0.067-2.233 0.067-20.555 0-37.218-16.663-37.218-37.218 0-0.786 0.024-1.566 0.072-2.339l-0.005 0.106v-39.385h630.154v39.385c0.043 0.668 0.067 1.448 0.067 2.233 0 20.555-16.663 37.218-37.218 37.218-0.786 0-1.566-0.024-2.339-0.072l0.106 0.005zM293.022 630.154c-0.007 0-0.016 0-0.024 0-3.959 0-7.168-3.209-7.168-7.168 0-1.985 0.807-3.782 2.111-5.080v0l66.521-66.521h39.385v-39.385l78.769-78.769v118.154h78.769v-196.923l78.769-78.769v275.692h78.769v-354.462l64.866-64.866c1.474-1.467 3.506-2.373 5.75-2.373 4.503 0 8.153 3.65 8.153 8.153 0 0.004 0 0.007 0 0.011v-0.001 492.308h-494.671zM776.35 27.373l-591.518 591.478c-7.056 7.055-16.803 11.419-27.569 11.419s-20.513-4.364-27.569-11.419l-0.197-0.197c-7.055-7.056-11.419-16.803-11.419-27.569s4.364-20.513 11.419-27.569v0l106.811-106.654v-338.708c0.134-43.449 35.32-78.635 78.756-78.769h338.721l67.348-67.348c7.056-7.055 16.803-11.419 27.569-11.419s20.513 4.364 27.569 11.419l0.197 0.197c7.020 7.050 11.36 16.773 11.36 27.51 0 10.796-4.387 20.567-11.477 27.627l-0.001 0.001zM315.077 118.154v259.938l78.769-78.769v-181.169h-78.769zM551.385 118.154h-78.769v102.4l78.769-78.769v-23.631z" />
19
+ =======
10
20
  <glyph unicode="&#xe600;" glyph-name="unspike" d="M787.692 748.308h-165.415c-16.187 46.218-59.431 78.769-110.277 78.769s-94.089-32.552-110.027-77.952l-0.25-0.817h-165.415c-0.668 0.043-1.448 0.067-2.233 0.067-20.555 0-37.218-16.663-37.218-37.218 0-0.786 0.024-1.566 0.072-2.339l-0.005 0.106v-39.385h630.154v39.385c0.043 0.668 0.067 1.448 0.067 2.233 0 20.555-16.663 37.218-37.218 37.218-0.786 0-1.566-0.024-2.339-0.072l0.106 0.005zM293.022 630.154c-0.007 0-0.016 0-0.024 0-3.959 0-7.168-3.209-7.168-7.168 0-1.985 0.807-3.782 2.111-5.080v0l66.521-66.521h39.385v-39.385l78.769-78.769v118.154h78.769v-196.923l78.769-78.769v275.692h78.769v-354.462l64.866-64.866c1.474-1.467 3.506-2.373 5.75-2.373 4.503 0 8.153 3.65 8.153 8.153 0 0.004 0 0.007 0 0.011v-0.001 492.308h-494.671zM776.35 27.373l-591.518 591.478c-7.056 7.055-16.803 11.419-27.569 11.419s-20.513-4.364-27.569-11.419l-0.197-0.197c-7.055-7.056-11.419-16.803-11.419-27.569s4.364-20.513 11.419-27.569v0l106.811-106.654v-338.708c0.134-43.449 35.32-78.635 78.756-78.769h338.721l67.348-67.348c7.056-7.055 16.803-11.419 27.569-11.419s20.513 4.364 27.569 11.419l0.197 0.197c7.020 7.050 11.36 16.773 11.36 27.51 0 10.796-4.387 20.567-11.477 27.627l-0.001 0.001zM315.077 118.154v259.938l78.769-78.769v-181.169h-78.769zM551.385 118.154h-78.769v102.4l78.769-78.769v-23.631z" />
11
21
  <glyph unicode="&#xe601;" glyph-name="dashboard" d="M275.692 78.769h157.538v236.308h157.538v-236.308h157.538v315.077h157.538l-362.575 381.44c-7.632 7.626-18.172 12.342-29.814 12.342s-22.182-4.716-29.814-12.343v0l-365.489-381.44h157.538v-315.077z" />
12
22
  <glyph unicode="&#xe602;" glyph-name="view" d="M512 787.693c-310.863 0-512-354.462-512-354.462s197.474-354.462 512-354.462c292.588 0 512 354.462 512 354.462s-215.788 354.462-512 354.462zM512 196.923c-130.509 0-236.308 105.799-236.308 236.308s105.799 236.308 236.308 236.308c130.509 0 236.308-105.799 236.308-236.308v0c0-130.509-105.799-236.308-236.308-236.308v0zM630.154 433.231c0-65.255-52.899-118.154-118.154-118.154s-118.154 52.899-118.154 118.154c0 65.255 52.899 118.154 118.154 118.154s118.154-52.899 118.154-118.154z" />
@@ -15,6 +25,7 @@
15
25
  <glyph unicode="&#xe605;" glyph-name="marked-star" d="M512 827.077l107.087-266.398 286.759-19.417-220.554-184.084 70.105-278.41-243.397 152.655-243.397-152.655 70.105 278.41-220.554 184.084 286.759 19.417 107.087 266.398z" />
16
26
  <glyph unicode="&#xe606;" glyph-name="archive" d="M787.692 748.308h-551.385v-275.692h551.385v275.692zM590.769 590.769h-157.538v39.385h157.538v-39.385zM787.692 433.231h-551.385v-275.692h551.385v275.692zM590.769 275.693h-157.538v39.385h157.538v-39.385zM866.462 866.462h-708.923c-21.752 0-39.385-17.633-39.385-39.385v0-748.308c0-21.752 17.633-39.385 39.385-39.385v0h708.923c21.752 0 39.385 17.633 39.385 39.385v0 748.308c0 21.752-17.633 39.385-39.385 39.385v0zM827.077 748.308v-630.154h-630.154v669.538h630.154v-39.385zM236.308 39.385h157.538v-39.385h-157.538v39.385zM630.154 39.385h157.538v-39.385h-157.538v39.385z" />
17
27
  <glyph unicode="&#xe607;" glyph-name="spike" d="M236.308 630.154v-512c0.134-43.449 35.32-78.635 78.756-78.769h393.859c43.449 0.134 78.635 35.32 78.769 78.756v512.013h-551.385zM393.846 118.154h-78.769v433.231h78.769v-433.231zM551.385 118.154h-78.769v433.231h78.769v-433.231zM708.923 118.154h-78.769v433.231h78.769v-433.231zM787.692 748.308h-165.415c-16.187 46.218-59.431 78.769-110.277 78.769s-94.089-32.552-110.027-77.952l-0.25-0.817h-165.415c-0.668 0.043-1.448 0.067-2.233 0.067-20.555 0-37.218-16.663-37.218-37.218 0-0.786 0.024-1.566 0.072-2.339l-0.005 0.106v-39.385h630.154v39.385c0.043 0.668 0.067 1.448 0.067 2.233 0 20.555-16.663 37.218-37.218 37.218-0.786 0-1.566-0.024-2.339-0.072l0.106 0.005z" />
28
+ >>>>>>> a08c0d67188170f83c5a6467642c6a78cfde8f31
18
29
  <glyph unicode="&#xe608;" glyph-name="personal" d="M945.231-0h-196.923c-21.752 0-39.385 17.633-39.385 39.385v0 157.538c0 21.752 17.633 39.385 39.385 39.385v0h196.923c0.346 0.011 0.752 0.018 1.16 0.018 21.121 0 38.242-17.122 38.242-38.242 0-0.408-0.006-0.814-0.019-1.219l0.001 0.059v-157.538c0.043-0.668 0.067-1.448 0.067-2.233 0-20.555-16.663-37.218-37.218-37.218-0.786 0-1.566 0.024-2.339 0.072l0.106-0.005zM708.923 236.308v118.154s1.221 78.769 39.385 78.769c15.754 8.192 78.769 9.886 78.769 39.385 0 195.764-158.698 354.462-354.462 354.462s-354.462-158.698-354.462-354.462v0c-0.058-2.458-0.090-5.353-0.090-8.257 0-125.955 61.699-237.5 156.523-306.059l1.105-0.761v78.769c0.332 43.369 35.4 78.437 78.737 78.769h260.325c0.165 0.002 0.359 0.003 0.554 0.003 29.952 0 54.233-24.281 54.233-54.233 0-0.195-0.001-0.39-0.003-0.584v0.030zM477.538 354.462c-77.448 5.673-138.133 69.901-138.133 148.303 0 3.249 0.104 6.474 0.31 9.672l-0.022-0.436c-0.183 2.762-0.287 5.987-0.287 9.236 0 78.402 60.685 142.63 137.646 148.274l0.487 0.029c77.465-5.8 138.119-70.077 138.119-148.522 0-3.172-0.099-6.321-0.295-9.444l0.021 0.427c0.21-2.952 0.33-6.397 0.33-9.87 0-78.614-61.323-142.905-138.743-147.648l-0.417-0.020h0.985zM846.769 433.231c-53.327 0-98.462-41.236-98.462-118.154v-118.154h196.923v118.154c0 78.769-47.262 118.154-98.462 118.154zM905.846 236.308h-118.154v78.769c0 34.304 9.019 78.769 59.077 78.769 60.298 0 59.077-43.323 59.077-78.769v-78.769z" />
19
30
  <glyph unicode="&#xe609;" glyph-name="global-search" d="M78.769 787.693h866.462v-39.385h-866.462zM78.769 669.539h196.923v-39.385h-196.923zM748.308 669.539h196.923v-39.385h-196.923zM827.077 551.385h118.154v-39.385h-118.154zM78.769 551.385h118.154v-39.385h-118.154zM78.769 433.231h118.154v-39.385h-118.154zM866.462 433.231h78.769v-39.385h-78.769zM590.769 315.077h-157.538l-39.385 78.769h236.308l-39.385-78.769zM630.154 472.616h-236.308l39.385 78.769h157.538l39.385-78.769zM512 708.923c-152.261 0-275.692-123.432-275.692-275.692s123.432-275.692 275.692-275.692c152.261 0 275.692 123.432 275.692 275.692v0c0 152.261-123.432 275.692-275.692 275.692v0zM512 236.308c-108.758 0-196.923 88.165-196.923 196.923s88.165 196.923 196.923 196.923c108.758 0 196.923-88.165 196.923-196.923v0c0-108.758-88.165-196.923-196.923-196.923v0zM708.923 315.077l-78.769-78.769 236.308-236.308c0.094 0 0.205-0.001 0.316-0.001 43.218 0 78.275 34.946 78.453 78.123v0.647z" />
20
31
  <glyph unicode="&#xe60a;" glyph-name="analytics" d="M433.231 787.693h157.538v-708.923h-157.538v708.923zM196.923 393.846h157.538v-315.077h-157.538v315.077zM669.538 551.385h157.538v-472.615h-157.538v472.615z" />
Binary file
Binary file
@@ -82,7 +82,7 @@ tags-input,
82
82
  }
83
83
 
84
84
  &:hover {
85
- cursor: pointer;
85
+ cursor: default;
86
86
  }
87
87
  .tags-input__remove-button {
88
88
  height: 1.8rem;
@@ -13,6 +13,15 @@ import {TreeSelectPill} from './TreeSelectPill';
13
13
  import {getPrefixedItemId, TreeSelectItem} from './TreeSelectItem';
14
14
  import {keyboardNavigation} from './KeyboardNavigation';
15
15
  import {WithPortal} from '../WithPortal';
16
+ import { DragDropContext, Droppable, Draggable, DropResult } from "react-beautiful-dnd";
17
+
18
+ const reorder = (list: Array<any>, startIndex: number, endIndex: number) => {
19
+ const result = Array.from(list);
20
+ const [removed] = result.splice(startIndex, 1);
21
+ result.splice(endIndex, 0, removed);
22
+
23
+ return result;
24
+ };
16
25
 
17
26
  interface IState<T> {
18
27
  value: Array<T>;
@@ -42,7 +51,10 @@ interface IPropsBase<T> extends IInputWrapper {
42
51
  singleLevelSearch?: boolean;
43
52
  placeholder?: string;
44
53
  searchPlaceholder?: string;
54
+ noResultsFoundMessage?: string;
55
+ dropdownInitiallyOpen?: boolean;
45
56
  zIndex?: number;
57
+ sortable?: boolean;
46
58
  'data-test-id'?: string;
47
59
  getLabel(item: T): string;
48
60
  getId(item: T): string;
@@ -112,7 +124,6 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
112
124
  this.onMouseDown = this.onMouseDown.bind(this);
113
125
  this.onKeyDown = this.onKeyDown.bind(this);
114
126
  this.onPressEsc = this.onPressEsc.bind(this);
115
-
116
127
  this.dropdownRef = React.createRef();
117
128
  this.ref = React.createRef();
118
129
  this.inputRef = React.createRef();
@@ -120,6 +131,7 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
120
131
  this.openDropdownRef = React.createRef();
121
132
  this.treeSelectRef = React.createRef();
122
133
  this.popperInstance = null;
134
+ this.onDragEnd = this.onDragEnd.bind(this);
123
135
  }
124
136
 
125
137
  inputFocus = () => {
@@ -185,6 +197,10 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
185
197
  document.addEventListener("mousedown", this.onMouseDown);
186
198
  document.addEventListener("keydown", this.onKeyDown);
187
199
  document.addEventListener("keydown", this.onPressEsc);
200
+
201
+ if (this.props.dropdownInitiallyOpen) {
202
+ this.setState({openDropdown: true});
203
+ }
188
204
  }
189
205
 
190
206
  componentWillUnmount(): void {
@@ -501,34 +517,39 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
501
517
  });
502
518
  }
503
519
  } else if (this.props.kind === 'asynchronous') {
504
- return this.state.options.map((item, i) => {
505
- let selectedItem = this.state.value.some((obj) =>
506
- this.props.getId(obj) === this.props.getId(item.value),
507
- );
520
+ if (this.state.options.length > 0) {
521
+ return this.state.options.map((item, i) => {
522
+ let selectedItem = this.state.value.some((obj) =>
523
+ this.props.getId(obj) === this.props.getId(item.value),
524
+ );
508
525
 
509
- return (
510
- <li
511
- key={i}
512
- className='suggestion-item suggestion-item--multi-select'
513
- onClick={(event) => {
514
- this.handleValue(event, item);
515
- }}
516
- >
517
- <button className="suggestion-item--btn" data-test-id="option">
518
- {this.props.optionTemplate
519
- ? this.props.optionTemplate(item.value)
520
- : (
521
- <span
522
- className={selectedItem ? 'suggestion-item--selected' : undefined}
523
- >
524
- {this.props.getLabel(item.value)}
525
- </span>
526
- )
527
- }
528
- </button>
529
- </li>
530
- );
531
- });
526
+ return (
527
+ <li
528
+ key={i}
529
+ className='suggestion-item suggestion-item--multi-select'
530
+ onClick={(event) => {
531
+ this.handleValue(event, item);
532
+ }}
533
+ >
534
+ <button className="suggestion-item--btn" data-test-id="option">
535
+ {this.props.optionTemplate
536
+ ? this.props.optionTemplate(item.value)
537
+ : (
538
+ <span
539
+ className={selectedItem ? 'suggestion-item--selected' : undefined}
540
+ >
541
+ {this.props.getLabel(item.value)}
542
+ </span>
543
+ )
544
+ }
545
+ </button>
546
+ </li>
547
+ );
548
+ });
549
+
550
+ } else {
551
+ return <li className="suggestion-item--nothing-found">{this.props.noResultsFoundMessage ?? 'Nothing found'}</li>;
552
+ }
532
553
  } else {
533
554
  return;
534
555
  }
@@ -591,18 +612,31 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
591
612
 
592
613
  if (this.props.kind === 'asynchronous') {
593
614
  if (this.state.searchFieldValue) {
594
- this.setState({
595
- loading: true,
596
- });
597
-
598
615
  this.ICancelFn = this.props.searchOptions(this.state.searchFieldValue, (items) => {
599
616
  this.setState({options: items, loading: false});
600
617
  this.popperInstance?.update();
601
618
  });
619
+ } else {
620
+ this.setState({options: this.state.firstBranchOptions, loading: false});
602
621
  }
603
622
  }
604
623
  }
605
624
 
625
+ onDragEnd(result: DropResult) {
626
+ if (!result.destination) {
627
+ return;
628
+ }
629
+
630
+ const value = reorder(
631
+ this.state.value,
632
+ result.source.index,
633
+ result.destination.index,
634
+ );
635
+ this.setState({
636
+ value: value,
637
+ });
638
+ }
639
+
606
640
  render() {
607
641
  if (this.props.preview) {
608
642
  return (
@@ -624,6 +658,43 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
624
658
  );
625
659
  }
626
660
 
661
+ const ListWrapper = this.props.sortable
662
+ ? ({children}: {children: React.ReactNode}) => (
663
+ <DragDropContext onDragEnd={this.onDragEnd}>
664
+ <Droppable droppableId="droppable" direction="horizontal">
665
+ {(provided, _snapshot) => (
666
+ <ul
667
+ className="tags-input__tag-list"
668
+ ref={provided.innerRef}
669
+ {...provided.droppableProps}
670
+ >
671
+ {children}
672
+ {provided.placeholder}
673
+ </ul>
674
+ )}
675
+ </Droppable>
676
+ </DragDropContext>
677
+ )
678
+ : ({children}: {children: React.ReactNode}) => <ul className="tags-input__tag-list">{children}</ul>;
679
+
680
+ const ItemWrapper = this.props.sortable
681
+ ? ({children, itemId, i}: {children: React.ReactNode, itemId: string, i: number}) => {
682
+ return (
683
+ <Draggable draggableId={itemId} index={i}>
684
+ {(provided2) => (
685
+ <div
686
+ ref={provided2.innerRef}
687
+ {...provided2.draggableProps}
688
+ {...provided2.dragHandleProps}
689
+ >
690
+ {children}
691
+ </div>
692
+ )}
693
+ </Draggable>
694
+ );
695
+ }
696
+ : ({children}: {children: React.ReactNode}) => <React.Fragment>{children}</React.Fragment>;
697
+
627
698
  return (
628
699
  <InputWrapper
629
700
  label={this.props.label}
@@ -672,7 +743,7 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
672
743
  </button>
673
744
  }
674
745
 
675
- <ul className="tags-input__tag-list">
746
+ <ListWrapper>
676
747
  {this.state.value.map((item, i: number) => {
677
748
  const Wrapper: React.ComponentType<{backgroundColor?: string}>
678
749
  = ({backgroundColor, children}) => (
@@ -684,25 +755,30 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
684
755
  backgroundColor={backgroundColor}
685
756
  onRemove={() => this.removeClick(i)}
686
757
  getBackgroundColor={this.props.getBackgroundColor}
758
+ draggable={this.props.sortable}
687
759
  >
688
760
  {children}
689
761
  </TreeSelectPill>
690
762
  );
691
763
 
764
+ const itemId = this.props.getId(item);
765
+
692
766
  return (
693
- <React.Fragment key={i}>
767
+ <ItemWrapper itemId={itemId} key={itemId} i={i}>
694
768
  {this.props.valueTemplate
695
769
  ? this.props.valueTemplate(item, Wrapper)
696
770
  : (
697
771
  <Wrapper>
698
- <span>{this.props.getLabel(item)}</span>
772
+ <span>
773
+ {this.props.getLabel(item)}
774
+ </span>
699
775
  </Wrapper>
700
776
  )
701
777
  }
702
- </React.Fragment>
778
+ </ItemWrapper>
703
779
  );
704
780
  })}
705
- </ul>
781
+ </ListWrapper>
706
782
 
707
783
  {this.state.value.length > 0
708
784
  ? (this.props.readOnly || this.props.disabled)
@@ -842,7 +918,11 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
842
918
  this.ICancelFn();
843
919
  }
844
920
 
845
- this.setState({searchFieldValue: event.target.value, options: []});
921
+ this.setState({
922
+ searchFieldValue: event.target.value,
923
+ options: [],
924
+ loading: true,
925
+ });
846
926
  this.popperInstance?.update();
847
927
  this.debounceFn();
848
928
  } else {
@@ -1,4 +1,6 @@
1
+ import classNames from 'classnames';
1
2
  import * as React from "react";
3
+ import {DragHandle} from '../DragHandle';
2
4
  import {Icon} from "../Icon";
3
5
  import {getTextColor} from '../Label';
4
6
 
@@ -10,19 +12,19 @@ interface IProps<T> {
10
12
  onRemove(): void;
11
13
  valueTemplate?(item: T, Wrapper: React.ElementType): React.ComponentType<T> | JSX.Element;
12
14
  getBackgroundColor?(item: T): string;
15
+ draggable?: boolean;
13
16
  }
14
17
 
15
18
  export class TreeSelectPill<T> extends React.Component<IProps<T>> {
16
19
  render() {
20
+ const classes = classNames('tags-input__tag-item tags-input__tag-item--multi-select', {
21
+ 'tags-input__tag-item--readonly': this.props.readOnly,
22
+ 'tags-input__tag-item--draggable': this.props.draggable,
23
+ });
24
+
17
25
  return (
18
26
  <li
19
- className={
20
- "tags-input__tag-item tags-input__tag-item--multi-select"
21
- + (this.props.readOnly ? ' tags-input__tag-item--readonly' : '')
22
- }
23
- onClick={() => (!this.props.readOnly && !this.props.disabled)
24
- && this.props.onRemove()
25
- }
27
+ className={classes}
26
28
  style={
27
29
  this.props.valueTemplate
28
30
  ? {backgroundColor: this.props.backgroundColor}
@@ -31,6 +33,9 @@ export class TreeSelectPill<T> extends React.Component<IProps<T>> {
31
33
  }
32
34
  data-test-id="item"
33
35
  >
36
+ {this.props.draggable && (
37
+ <DragHandle blank={true} dotsInRow='3' dotRows='4' />
38
+ )}
34
39
  <span
35
40
  className="tags-input__helper-box"
36
41
  style={{
@@ -43,9 +48,15 @@ export class TreeSelectPill<T> extends React.Component<IProps<T>> {
43
48
  {this.props.children}
44
49
 
45
50
  {!this.props.readOnly
46
- && <span className="tags-input__remove-button" data-test-id="remove">
51
+ && <button
52
+ className="tags-input__remove-button"
53
+ data-test-id="remove"
54
+ onClick={() => (!this.props.readOnly && !this.props.disabled)
55
+ && this.props.onRemove()
56
+ }
57
+ >
47
58
  <Icon name="close-small"></Icon>
48
- </span>
59
+ </button>
49
60
  }
50
61
  </span>
51
62
  </li>
@@ -4,7 +4,7 @@ import {Avatar, IPropsAvatar} from './avatar';
4
4
  import {AvatarWrapper} from './avatar-wrapper';
5
5
  import {AvatarContentNumber} from './avatar-number';
6
6
  import {AvatarPlaceholder, IPropsAvatarPlaceholder} from './avatar-placeholder';
7
- import { Spacer } from '../Spacer';
7
+ import {Spacer} from '@superdesk/common';
8
8
  import {WithPopover} from '../WithPopover';
9
9
 
10
10
  export type IAvatarInGroup = Omit<IPropsAvatar, 'size'>;
@@ -99,7 +99,7 @@ export { ContentListItem } from './components/Lists/ContentList';
99
99
  export { MultiSelect } from './components/MultiSelect';
100
100
  export { ResizablePanels } from './components/ResizablePanels';
101
101
  export { WithPopover } from './components/WithPopover';
102
- export { Spacer, SpacerBlock } from './components/Spacer';
102
+ export { Spacer, SpacerBlock } from '@superdesk/common';
103
103
  export { ResizeObserverComponent } from './components/ResizeObserverComponent';
104
104
  export { DragHandleDots } from './components/DragHandleDots';
105
105
  export { DragHandle } from './components/DragHandle';