superdesk-ui-framework 3.0.6 → 3.0.8

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 (33) hide show
  1. package/app/styles/_sd-tag-input.scss +29 -10
  2. package/app-typescript/components/Lists/ContentList.tsx +28 -27
  3. package/app-typescript/components/Lists/TableList.tsx +140 -126
  4. package/app-typescript/components/MultiSelect.tsx +2 -3
  5. package/app-typescript/components/SingleAndDoubleClickFunction.tsx +21 -0
  6. package/app-typescript/components/TreeSelect.tsx +506 -243
  7. package/dist/examples.bundle.js +1468 -1186
  8. package/dist/playgrounds/react-playgrounds/EditorTest.tsx +18 -10
  9. package/dist/playgrounds/react-playgrounds/Multiedit.tsx +15 -13
  10. package/dist/playgrounds/react-playgrounds/RundownEditor.tsx +136 -125
  11. package/dist/react/Dropdowns.tsx +134 -85
  12. package/dist/react/MultiSelect.tsx +2 -2
  13. package/dist/react/TreeSelect.tsx +39 -27
  14. package/dist/superdesk-ui.bundle.css +26 -9
  15. package/dist/superdesk-ui.bundle.js +1015 -809
  16. package/dist/vendor.bundle.js +14 -14
  17. package/examples/pages/playgrounds/react-playgrounds/EditorTest.tsx +18 -10
  18. package/examples/pages/playgrounds/react-playgrounds/Multiedit.tsx +15 -13
  19. package/examples/pages/playgrounds/react-playgrounds/RundownEditor.tsx +136 -125
  20. package/examples/pages/react/Dropdowns.tsx +134 -85
  21. package/examples/pages/react/MultiSelect.tsx +2 -2
  22. package/examples/pages/react/TreeSelect.tsx +39 -27
  23. package/package.json +2 -2
  24. package/react/components/Lists/ContentList.d.ts +2 -5
  25. package/react/components/Lists/ContentList.js +20 -25
  26. package/react/components/Lists/TableList.d.ts +4 -7
  27. package/react/components/Lists/TableList.js +66 -60
  28. package/react/components/MultiSelect.d.ts +1 -1
  29. package/react/components/MultiSelect.js +1 -1
  30. package/react/components/SingleAndDoubleClickFunction.d.ts +6 -0
  31. package/react/components/SingleAndDoubleClickFunction.js +19 -0
  32. package/react/components/TreeSelect.d.ts +17 -9
  33. package/react/components/TreeSelect.js +249 -74
@@ -69,7 +69,7 @@ export class MultiselectDocs extends React.Component<{}, IState> {
69
69
  showSelectAll
70
70
  zIndex={2000}
71
71
  placeholder='Select a color'
72
- optionLabel='name'
72
+ optionLabel={(option) => `${option.name} :: ${option.colorCode}`}
73
73
  required
74
74
  tabindex={1}
75
75
  label={'This is Label'}
@@ -106,10 +106,10 @@ export class MultiselectDocs extends React.Component<{}, IState> {
106
106
  <MultiSelect
107
107
  value={this.state.value2}
108
108
  options={ItemArr}
109
+ optionLabel={(option) => `${option.name} :: ${option.colorCode}`}
109
110
  onChange={(e: any) => this.setState({value2: e})}
110
111
  filter
111
112
  showSelectAll
112
- optionLabel='name'
113
113
  itemTemplate={(option) => {
114
114
  if (option) {
115
115
  return (
@@ -20,41 +20,53 @@ let options = [
20
20
  {
21
21
  value: {name: 'Sub-category1'},
22
22
  children: [
23
- {value: {name: 'Item20'}}
23
+ {value: {name: 'Item31'}},
24
+ // {value: {name: 'Item32'}},
25
+ // {value: {name: 'Item33'}},
26
+ // {value: {name: 'Item34'}},
27
+
24
28
  ]
25
29
  },
26
30
  {
27
31
  value: {name: 'Sub-category2'},
28
32
  children: [
29
- {value: {name: 'Item21'}}
33
+ {value: {name: 'Item41'}},
34
+ {value: {name: 'Item42'}},
35
+ {value: {name: 'Item43'}}
30
36
  ]
31
- }
32
- ,
37
+ },
33
38
  {
34
39
  value: {name: 'Sub-category3'},
35
40
  children: [
36
- {value: {name: 'Item22'}}
41
+ {value: {name: 'Item50'}},
42
+ {value: {name: 'Item51'}},
43
+ {value: {name: 'Item53'}}
37
44
  ]
38
- }
39
- ,
45
+ },
40
46
  {
41
47
  value: {name: 'Sub-category4'},
42
48
  children: [
43
- {value: {name: 'Item23'}}
49
+ {value: {name: 'Item23'}},
50
+ {value: {name: 'Item41'}},
51
+ {value: {name: 'Item42'}},
52
+ {value: {name: 'Item43'}}
44
53
  ]
45
- }
46
- ,
54
+ },
47
55
  {
48
56
  value: {name: 'Sub-category5'},
49
57
  children: [
50
- {value: {name: 'Item24'}}
58
+ {value: {name: 'Item24'}},
59
+ {value: {name: 'Item41'}},
60
+ {value: {name: 'Item42'}},
61
+ {value: {name: 'Item43'}}
51
62
  ]
52
- }
53
- ,
63
+ },
54
64
  {
55
65
  value: {name: 'Sub-category6'},
56
66
  children: [
57
- {value: {name: 'Item25'}}
67
+ {value: {name: 'Item50'}},
68
+ {value: {name: 'Item51'}},
69
+ {value: {name: 'Item52'}}
58
70
  ]
59
71
  }
60
72
  ]
@@ -65,9 +77,9 @@ let options = [
65
77
  {
66
78
  value: {name: 'Item8'}
67
79
  },
68
- {
69
- value: {name: 'Item9'}
70
- }
80
+ // {
81
+ // value: {name: 'Item9'}
82
+ // }
71
83
  ]
72
84
  },
73
85
  {
@@ -164,7 +176,7 @@ function searchOptions(
164
176
  callback: (res: any) => void,
165
177
  ): ICancelFn {
166
178
  let timeout = setTimeout(() => {
167
-
179
+
168
180
  callback(
169
181
  fetchedArr
170
182
  .filter((item: any) => item.display_name.toLocaleLowerCase().includes(term.toLocaleLowerCase()))
@@ -188,7 +200,7 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
188
200
  inputValue: '',
189
201
  arr: []
190
202
  }
191
-
203
+
192
204
 
193
205
  this.handleChange = this.handleChange.bind(this);
194
206
  }
@@ -197,7 +209,7 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
197
209
  if(option.item) {
198
210
  e.stopPropagation();
199
211
  e.preventDefault();
200
-
212
+
201
213
  this.setState({
202
214
  options: option.item
203
215
  })
@@ -219,7 +231,7 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
219
231
  />
220
232
  `}
221
233
  </Markup.ReactMarkupCodePreview>
222
-
234
+
223
235
  <Markup.ReactMarkup>
224
236
  <Markup.ReactMarkupPreview>
225
237
  <div className='docs-page__content-row docs-page__content-row--no-margin'>
@@ -234,7 +246,7 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
234
246
  selectBranchWithChildren={true}
235
247
  allowMultiple
236
248
  fullWidth
237
- singleLevelSearch
249
+ //singleLevelSearch
238
250
  required
239
251
  info={'Info Message'}
240
252
  error={'Error Message'}
@@ -247,7 +259,7 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
247
259
  <span>{item.name}</span>
248
260
  </Wrapper>
249
261
  );
250
- }}
262
+ }}
251
263
  />
252
264
  </div>
253
265
  </div>
@@ -277,10 +289,10 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
277
289
  <span>{item.name}</span>
278
290
  </Wrapper>
279
291
  );
280
- }}
292
+ }}
281
293
  />
282
294
  `}</Markup.ReactMarkupCode>
283
-
295
+
284
296
  </Markup.ReactMarkup>
285
297
 
286
298
  <p className='docs-page__paragraph'>Asynchronous mode in TreeSelect component.</p>
@@ -320,7 +332,7 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
320
332
  allowMultiple={true}
321
333
  />
322
334
  `}</Markup.ReactMarkupCode>
323
-
335
+
324
336
  </Markup.ReactMarkup>
325
337
 
326
338
  <p className='docs-page__paragraph'>TreeSelect with custom template.</p>
@@ -415,7 +427,7 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
415
427
  <Prop name='getOptions' isRequired={false} type='Function' default='/' description='An array of selectitems to display as the available options.'/>
416
428
  <Prop name='searchOptions' isRequired={false} type='Function' default='/' description='function will be called when a search is initiated from UI.'/>
417
429
  </PropsList>
418
-
430
+
419
431
  </section>
420
432
  )
421
433
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "superdesk-ui-framework",
3
- "version": "3.0.6",
3
+ "version": "3.0.8",
4
4
  "license": "AGPL-3.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -84,7 +84,7 @@
84
84
  "dependencies": {
85
85
  "@material-ui/lab": "^4.0.0-alpha.56",
86
86
  "@popperjs/core": "^2.4.0",
87
- "@superdesk/primereact": "^5.0.2-8",
87
+ "@superdesk/primereact": "^5.0.2-10",
88
88
  "@types/node": "^14.10.2",
89
89
  "chart.js": "^2.9.3",
90
90
  "date-fns": "2.7.0",
@@ -17,11 +17,8 @@ interface IPropsItem {
17
17
  onDoubleClick?(): void;
18
18
  }
19
19
  declare class ContentListItem extends React.PureComponent<IPropsItem> {
20
- private timer;
21
- private delay;
22
- private prevent;
23
- onSingleClick: () => void;
24
- onDoubleClick: () => void;
20
+ private multiClickHandler;
21
+ constructor(props: IPropsItem);
25
22
  onActionMenuClick: (event: React.MouseEvent<HTMLElement>) => void;
26
23
  render(): JSX.Element;
27
24
  }
@@ -40,46 +40,41 @@ Object.defineProperty(exports, "__esModule", { value: true });
40
40
  exports.ContentListItem = exports.ContentList = void 0;
41
41
  var React = __importStar(require("react"));
42
42
  var classnames_1 = __importDefault(require("classnames"));
43
+ var SingleAndDoubleClickFunction_1 = require("./../SingleAndDoubleClickFunction");
43
44
  var ContentListItem = /** @class */ (function (_super) {
44
45
  __extends(ContentListItem, _super);
45
- function ContentListItem() {
46
- var _this = _super !== null && _super.apply(this, arguments) || this;
47
- _this.delay = 200;
48
- _this.prevent = false;
49
- _this.onSingleClick = function () {
50
- var selection = window.getSelection();
51
- _this.timer = setTimeout(function () {
52
- if (!_this.prevent && _this.props.onClick && selection) {
53
- if (selection.toString().length < 1) {
54
- _this.props.onClick();
55
- }
56
- }
57
- }, _this.delay);
58
- };
59
- _this.onDoubleClick = function () {
60
- clearTimeout(_this.timer);
61
- _this.prevent = true;
62
- if (_this.props.onDoubleClick) {
63
- _this.props.onDoubleClick();
64
- }
65
- setTimeout(function () {
66
- _this.prevent = false;
67
- }, _this.delay);
68
- };
46
+ function ContentListItem(props) {
47
+ var _this = _super.call(this, props) || this;
69
48
  _this.onActionMenuClick = function (event) {
70
49
  event.preventDefault();
71
50
  event.stopPropagation();
72
51
  };
52
+ _this.multiClickHandler = (0, SingleAndDoubleClickFunction_1.setupSingleAndDoubleClick)();
73
53
  return _this;
74
54
  }
75
55
  ContentListItem.prototype.render = function () {
56
+ var _this = this;
76
57
  var classes = (0, classnames_1.default)('sd-list-item sd-shadow--z1', {
77
58
  'sd-list-item--activated': this.props.activated,
78
59
  'sd-list-item--selected': this.props.selected,
79
60
  'fetched': this.props.archived,
80
61
  'actioning': this.props.loading,
81
62
  });
82
- return (React.createElement("div", { role: 'listitem', className: classes, onClick: this.onSingleClick, onDoubleClick: this.onDoubleClick },
63
+ return (React.createElement("div", { role: 'listitem', className: classes, onClick: function (e) { return _this.multiClickHandler(e, {
64
+ onSingleClick: function () {
65
+ var selection = window.getSelection();
66
+ if (_this.props.onClick && selection) {
67
+ if (selection.toString().length < 1) {
68
+ _this.props.onClick();
69
+ }
70
+ }
71
+ },
72
+ onDoubleClick: function () {
73
+ if (_this.props.onDoubleClick) {
74
+ _this.props.onDoubleClick();
75
+ }
76
+ },
77
+ }); } },
83
78
  this.props.locked
84
79
  ? React.createElement("div", { className: "sd-list-item__border sd-list-item__border--locked" })
85
80
  : React.createElement("div", { className: "sd-list-item__border" }),
@@ -19,10 +19,10 @@ export interface IPropsArrayItem {
19
19
  end?: React.ReactNode;
20
20
  action?: React.ReactNode;
21
21
  hexColor?: string;
22
- onClick?(): void;
23
- onDoubleClick?(): void;
24
22
  locked?: boolean;
25
23
  positionLocked?: boolean;
24
+ onClick?(): void;
25
+ onDoubleClick?(): void;
26
26
  }
27
27
  interface IState {
28
28
  items: Array<IPropsArrayItem>;
@@ -53,11 +53,8 @@ export interface IPropsItem {
53
53
  itemsDropdown?(index?: number): Array<IMenuItem | ISubmenu | IMenuGroup | 'divider'>;
54
54
  }
55
55
  declare class TableListItem extends React.PureComponent<IPropsItem> {
56
- private timer;
57
- private delay;
58
- private prevent;
59
- onSingleClick: () => void;
60
- onDoubleClick: () => void;
56
+ private multiClickHandler;
57
+ constructor(props: IPropsItem);
61
58
  onActionMenuClick: (event: React.MouseEvent<HTMLElement>) => void;
62
59
  render(): JSX.Element;
63
60
  }
@@ -50,12 +50,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
50
50
  Object.defineProperty(exports, "__esModule", { value: true });
51
51
  exports.TableListItem = exports.TableList = void 0;
52
52
  var React = __importStar(require("react"));
53
+ var react_dom_1 = __importDefault(require("react-dom"));
53
54
  var classnames_1 = __importDefault(require("classnames"));
54
55
  var react_beautiful_dnd_1 = require("react-beautiful-dnd");
55
56
  var Tooltip_1 = require("../Tooltip");
56
57
  var Button_1 = require("../Button");
57
58
  var Dropdown_1 = require("../Dropdown");
58
- var react_dom_1 = __importDefault(require("react-dom"));
59
+ var SingleAndDoubleClickFunction_1 = require("./../SingleAndDoubleClickFunction");
59
60
  var reorder = function (list, startIndex, endIndex) {
60
61
  var result = Array.from(list);
61
62
  var removed = result.splice(startIndex, 1)[0];
@@ -121,30 +122,37 @@ var TableList = /** @class */ (function (_super) {
121
122
  ? _this.props.itemsDropdown(index)
122
123
  : []; } })
123
124
  : React.createElement("div", __assign({ ref: provided2.innerRef }, provided2.draggableProps, provided2.dragHandleProps),
124
- React.createElement(TableListItem, { dragAndDrop: _this.props.dragAndDrop, start: item.start, center: item.center, end: item.end, action: item.action, onClick: item.onClick ? item.onClick : undefined, onDoubleClick: item.onDoubleClick
125
+ React.createElement(TableListItem, { dragAndDrop: _this.props.dragAndDrop, start: item.start, center: item.center, end: item.end, action: item.action, onClick: item.onClick
126
+ ? item.onClick
127
+ : undefined, onDoubleClick: item.onDoubleClick
125
128
  ? item.onDoubleClick
126
129
  : undefined, addItem: _this.props.addItem, itemsDropdown: function () { return _this.props.itemsDropdown
127
130
  ? _this.props.itemsDropdown(index)
128
131
  : []; }, hexColor: item.hexColor, locked: item.locked, positionLocked: item.positionLocked, onAddItem: function () { return _this.props.onAddItem
129
132
  && _this.props.onAddItem(index, item); }, showDragHandle: _this.props.showDragHandle }))); })); }),
130
133
  provided.placeholder,
131
- (_this.props.addItem && !_this.props.readOnly) &&
132
- React.createElement("div", { className: "table-list__add-item table-list__item--margin" },
134
+ (_this.props.addItem && !_this.props.readOnly)
135
+ && React.createElement("div", { className: "table-list__add-item table-list__item--margin" },
133
136
  React.createElement(Tooltip_1.Tooltip, { text: 'Add item', flow: 'top', appendToBody: true },
134
137
  React.createElement("div", { className: 'table-list__add-item--container sd-margin-x--auto' }, _this.dropDown()))))); }))
135
138
  : React.createElement("div", { role: 'list', className: classes },
136
- this.state.items.map(function (item, index) { return (React.createElement(TableListItem, { key: index, start: item.start, center: item.center, end: item.end, action: item.action, onClick: item.onClick ? item.onClick : undefined, onDoubleClick: item.onDoubleClick
139
+ this.state.items.map(function (item, index) { return (React.createElement(TableListItem, { key: index, start: item.start, center: item.center, end: item.end, action: item.action, onClick: item.onClick
140
+ ? item.onClick
141
+ : undefined, onDoubleClick: item.onDoubleClick
137
142
  ? item.onDoubleClick
138
- : undefined, addItem: _this.props.addItem, itemsDropdown: function () { return _this.props.itemsDropdown ? _this.props.itemsDropdown(index) : []; }, hexColor: item.hexColor, locked: item.locked, positionLocked: item.positionLocked, onAddItem: function () { return _this.props.onAddItem
143
+ : undefined, addItem: _this.props.addItem, itemsDropdown: function () { return _this.props.itemsDropdown
144
+ ? _this.props.itemsDropdown(index)
145
+ : []; }, hexColor: item.hexColor, locked: item.locked, positionLocked: item.positionLocked, onAddItem: function () { return _this.props.onAddItem
139
146
  && _this.props.onAddItem(index, item); } })); }),
140
- (this.props.addItem && !this.props.readOnly) &&
141
- React.createElement("div", { className: "table-list__add-item table-list__item--margin" },
147
+ (this.props.addItem && !this.props.readOnly)
148
+ && React.createElement("div", { className: "table-list__add-item table-list__item--margin" },
142
149
  React.createElement(Tooltip_1.Tooltip, { text: 'Add item', flow: 'top', appendToBody: true },
143
150
  React.createElement("div", { className: 'table-list__add-item--container sd-margin-x--auto' }, this.dropDown()))))
144
- : (this.props.addItem && !this.props.readOnly) ? React.createElement("div", { role: 'list', className: classes },
145
- React.createElement("div", { className: "table-list__add-item table-list__item--margin" },
146
- React.createElement(Tooltip_1.Tooltip, { text: 'Add item', flow: 'top', appendToBody: true },
147
- React.createElement("div", { className: 'table-list__add-item--container sd-margin-x--auto' }, this.dropDown()))))
151
+ : (this.props.addItem && !this.props.readOnly)
152
+ ? React.createElement("div", { role: 'list', className: classes },
153
+ React.createElement("div", { className: "table-list__add-item table-list__item--margin" },
154
+ React.createElement(Tooltip_1.Tooltip, { text: 'Add item', flow: 'top', appendToBody: true },
155
+ React.createElement("div", { className: 'table-list__add-item--container sd-margin-x--auto' }, this.dropDown()))))
148
156
  : null);
149
157
  };
150
158
  return TableList;
@@ -152,39 +160,13 @@ var TableList = /** @class */ (function (_super) {
152
160
  exports.TableList = TableList;
153
161
  var TableListItem = /** @class */ (function (_super) {
154
162
  __extends(TableListItem, _super);
155
- function TableListItem() {
156
- var _this = _super !== null && _super.apply(this, arguments) || this;
157
- _this.delay = 200;
158
- _this.prevent = false;
159
- _this.onSingleClick = function () {
160
- var selection = window.getSelection();
161
- _this.timer = setTimeout(function () {
162
- if (!_this.prevent && _this.props.onClick && selection) {
163
- if (_this.props.dragAndDrop) {
164
- _this.props.onClick();
165
- }
166
- else {
167
- if (selection.toString().length < 1) {
168
- _this.props.onClick();
169
- }
170
- }
171
- }
172
- }, _this.delay);
173
- };
174
- _this.onDoubleClick = function () {
175
- clearTimeout(_this.timer);
176
- _this.prevent = true;
177
- if (_this.props.onDoubleClick) {
178
- _this.props.onDoubleClick();
179
- }
180
- setTimeout(function () {
181
- _this.prevent = false;
182
- }, _this.delay);
183
- };
163
+ function TableListItem(props) {
164
+ var _this = _super.call(this, props) || this;
184
165
  _this.onActionMenuClick = function (event) {
185
166
  event.preventDefault();
186
167
  event.stopPropagation();
187
168
  };
169
+ _this.multiClickHandler = (0, SingleAndDoubleClickFunction_1.setupSingleAndDoubleClick)();
188
170
  return _this;
189
171
  }
190
172
  TableListItem.prototype.render = function () {
@@ -196,30 +178,52 @@ var TableListItem = /** @class */ (function (_super) {
196
178
  'table-list__item--position-locked': this.props.positionLocked,
197
179
  'table-list__item--drag-handles-always': !this.props.showDragHandle,
198
180
  'table-list__item--drag-handles-none': this.props.showDragHandle === 'none',
181
+ 'table-list__item--margin': !this.props.addItem,
199
182
  });
200
- return (this.props.addItem ?
201
- React.createElement("div", { className: 'table-list__item-container' },
202
- React.createElement("div", { role: 'listitem', onClick: function () { return _this.onSingleClick(); }, onDoubleClick: function () { return _this.onDoubleClick(); }, className: classes },
183
+ var Wrapper = this.props.addItem
184
+ ? function (_a) {
185
+ var children = _a.children;
186
+ return (React.createElement("div", { className: 'table-list__item-container' }, children));
187
+ }
188
+ : function (_a) {
189
+ var children = _a.children;
190
+ return children;
191
+ };
192
+ return (React.createElement(Wrapper, null,
193
+ React.createElement(React.Fragment, null,
194
+ React.createElement("div", { role: 'listitem', className: classes, onClick: function (e) { return _this.multiClickHandler(e, {
195
+ onSingleClick: function () {
196
+ var selection = window.getSelection();
197
+ if (_this.props.onClick && selection) {
198
+ if (_this.props.dragAndDrop) {
199
+ _this.props.onClick();
200
+ }
201
+ else {
202
+ if (selection.toString().length < 1) {
203
+ _this.props.onClick();
204
+ }
205
+ }
206
+ }
207
+ },
208
+ onDoubleClick: function () {
209
+ if (_this.props.onDoubleClick) {
210
+ _this.props.onDoubleClick();
211
+ }
212
+ },
213
+ }); } },
203
214
  React.createElement("div", { className: 'table-list__item-border', style: { backgroundColor: this.props.hexColor } }),
204
215
  React.createElement("div", { className: 'table-list__item-content' },
205
216
  React.createElement("div", { className: 'table-list__item-content-block' }, this.props.start && this.props.start),
206
217
  React.createElement("div", { className: 'table-list__item-content-block table-list__item-content-block--center' }, this.props.center && this.props.center),
207
218
  React.createElement("div", { className: 'table-list__item-content-block' }, this.props.end && this.props.end)),
208
- this.props.action &&
209
- React.createElement("div", { className: 'table-list__slide-in-actions', onClick: this.onActionMenuClick }, this.props.action)),
210
- React.createElement("div", { className: 'table-list__add-bar-container' },
211
- React.createElement(Tooltip_1.Tooltip, { text: 'Add item', flow: 'top', appendToBody: true },
212
- React.createElement("div", { className: 'table-list__add-bar' },
213
- React.createElement(Dropdown_1.Dropdown, { onChange: this.props.onAddItem, items: this.props.itemsDropdown ? this.props.itemsDropdown() : [] },
214
- React.createElement(Button_1.Button, { type: "primary", icon: "plus-large", text: "Add item", size: "small", shape: "round", iconOnly: true, onClick: function () { return false; } }))))))
215
- : React.createElement("div", { role: 'listitem', className: "".concat(classes, " table-list__item--margin"), onClick: function () { return _this.onSingleClick(); }, onDoubleClick: function () { return _this.onDoubleClick(); } },
216
- React.createElement("div", { className: 'table-list__item-border', style: { backgroundColor: this.props.hexColor } }),
217
- React.createElement("div", { className: 'table-list__item-content' },
218
- React.createElement("div", { className: 'table-list__item-content-block' }, this.props.start && this.props.start),
219
- React.createElement("div", { className: 'table-list__item-content-block table-list__item-content-block--center' }, this.props.center && this.props.center),
220
- React.createElement("div", { className: 'table-list__item-content-block' }, this.props.end && this.props.end)),
221
- this.props.action &&
222
- React.createElement("div", { className: 'table-list__slide-in-actions', onClick: this.onActionMenuClick }, this.props.action)));
219
+ this.props.action
220
+ && React.createElement("div", { className: 'table-list__slide-in-actions', onClick: this.onActionMenuClick }, this.props.action)),
221
+ this.props.addItem
222
+ && React.createElement("div", { className: 'table-list__add-bar-container' },
223
+ React.createElement(Tooltip_1.Tooltip, { text: 'Add item', flow: 'top', appendToBody: true },
224
+ React.createElement("div", { className: 'table-list__add-bar' },
225
+ React.createElement(Dropdown_1.Dropdown, { onChange: this.props.onAddItem, items: this.props.itemsDropdown ? this.props.itemsDropdown() : [] },
226
+ React.createElement(Button_1.Button, { type: "primary", icon: "plus-large", text: "Add item", size: "small", shape: "round", iconOnly: true, onClick: function () { return false; } }))))))));
223
227
  };
224
228
  return TableListItem;
225
229
  }(React.PureComponent));
@@ -235,7 +239,9 @@ var PortalItem = /** @class */ (function (_super) {
235
239
  var snapshot = this.props.snapshot;
236
240
  var usePortal = snapshot.isDragging;
237
241
  var child = (React.createElement("div", __assign({ ref: provided.innerRef }, provided.draggableProps, provided.dragHandleProps),
238
- React.createElement(TableListItem, { dragAndDrop: this.props.dragAndDrop, start: this.props.item.start, center: this.props.item.center, end: this.props.item.end, action: this.props.item.action, onClick: this.props.item.onClick ? this.props.item.onClick : undefined, onDoubleClick: this.props.item.onDoubleClick
242
+ React.createElement(TableListItem, { dragAndDrop: this.props.dragAndDrop, start: this.props.item.start, center: this.props.item.center, end: this.props.item.end, action: this.props.item.action, onClick: this.props.item.onClick
243
+ ? this.props.item.onClick
244
+ : undefined, onDoubleClick: this.props.item.onDoubleClick
239
245
  ? this.props.item.onDoubleClick
240
246
  : undefined, addItem: this.props.addItem, itemsDropdown: this.props.itemsDropdown, hexColor: this.props.item.hexColor, locked: this.props.item.locked, positionLocked: this.props.item.positionLocked, onAddItem: function () { return _this.props.onAddItem; }, showDragHandle: this.props.showDragHandle })));
241
247
  if (!usePortal) {
@@ -3,7 +3,6 @@ interface IProps<T> {
3
3
  value: Array<T>;
4
4
  options: Array<T>;
5
5
  placeholder?: string;
6
- optionLabel: string;
7
6
  emptyFilterMessage?: string;
8
7
  filterPlaceholder?: string;
9
8
  maxSelectedLabels?: number;
@@ -14,6 +13,7 @@ interface IProps<T> {
14
13
  showClear?: boolean;
15
14
  showSelectAll?: boolean;
16
15
  zIndex?: number;
16
+ optionLabel: (option: T) => string;
17
17
  itemTemplate?(item: any): JSX.Element | undefined;
18
18
  selectedItemTemplate?(value: any): JSX.Element | undefined;
19
19
  onChange(newValue: Array<T>): void;
@@ -66,7 +66,7 @@ var MultiSelect = /** @class */ (function (_super) {
66
66
  React.createElement(multiselect_1.MultiSelect, { panelClassName: classes, value: this.props.value, options: this.props.options, onChange: function (_a) {
67
67
  var value = _a.value;
68
68
  return _this.props.onChange(value);
69
- }, display: "chip", zIndex: this.props.zIndex, filter: this.props.filter, filterBy: this.props.optionLabel, appendTo: document.body, placeholder: this.props.placeholder, optionLabel: this.props.optionLabel, emptyFilterMessage: this.props.emptyFilterMessage, filterPlaceholder: this.props.filterPlaceholder, itemTemplate: this.props.itemTemplate, selectedItemTemplate: this.props.selectedItemTemplate, maxSelectedLabels: (_a = this.props.maxSelectedLabels) !== null && _a !== void 0 ? _a : 4, selectedItemsLabel: this.props.selectedItemsLabel, ariaLabelledBy: this.htmlId + 'label', tabIndex: this.props.tabIndex ? this.props.tabIndex : '0', showClear: this.props.showClear, disabled: this.props.disabled, inputId: this.htmlId })));
69
+ }, display: "chip", zIndex: this.props.zIndex, filter: this.props.filter, appendTo: document.body, placeholder: this.props.placeholder, optionLabel: function (option) { return _this.props.optionLabel(option); }, emptyFilterMessage: this.props.emptyFilterMessage, filterPlaceholder: this.props.filterPlaceholder, itemTemplate: this.props.itemTemplate, selectedItemTemplate: this.props.selectedItemTemplate, maxSelectedLabels: (_a = this.props.maxSelectedLabels) !== null && _a !== void 0 ? _a : 4, selectedItemsLabel: this.props.selectedItemsLabel, ariaLabelledBy: this.htmlId + 'label', tabIndex: this.props.tabIndex ? this.props.tabIndex : '0', showClear: this.props.showClear, disabled: this.props.disabled, inputId: this.htmlId })));
70
70
  };
71
71
  return MultiSelect;
72
72
  }(React.Component));
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export interface ICallbacks {
3
+ onSingleClick: (event: React.MouseEvent) => void;
4
+ onDoubleClick: (event: React.MouseEvent) => void;
5
+ }
6
+ export declare function setupSingleAndDoubleClick(): (event: React.MouseEvent, cb: ICallbacks) => void;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setupSingleAndDoubleClick = void 0;
4
+ function setupSingleAndDoubleClick() {
5
+ var timer;
6
+ var delay;
7
+ return function (event, cb) {
8
+ clearTimeout(timer);
9
+ if (event.nativeEvent.detail === 1) {
10
+ timer = window.setTimeout(function () {
11
+ cb.onSingleClick(event);
12
+ }, delay);
13
+ }
14
+ else if (event.nativeEvent.detail === 2) {
15
+ cb.onDoubleClick(event);
16
+ }
17
+ };
18
+ }
19
+ exports.setupSingleAndDoubleClick = setupSingleAndDoubleClick;
@@ -2,15 +2,16 @@ import * as React from "react";
2
2
  interface IState<T> {
3
3
  value: Array<T>;
4
4
  options: Array<ITreeNode<T>>;
5
- firstBranchOptions: Array<any>;
5
+ firstBranchOptions: Array<ITreeNode<T>>;
6
6
  openDropdown: boolean;
7
- activeTree: Array<any>;
8
- filterArr: Array<any>;
7
+ activeTree: Array<Array<ITreeNode<T>>>;
8
+ filterArr: Array<ITreeNode<T>>;
9
9
  searchFieldValue: string;
10
- buttonTree: Array<any>;
11
- buttonValue: any;
10
+ buttonTree: Array<ITreeNode<T>>;
11
+ buttonValue: ITreeNode<T> | null;
12
12
  buttonMouseEvent: boolean;
13
13
  loading: boolean;
14
+ buttonTarget: Array<string>;
14
15
  }
15
16
  interface IPropsBase<T> {
16
17
  value?: Array<T>;
@@ -37,17 +38,18 @@ interface IPropsBase<T> {
37
38
  getBackgroundColor?(item: T): string;
38
39
  getBorderColor?(item: T): string;
39
40
  optionTemplate?(item: T): React.ComponentType<T> | JSX.Element;
40
- valueTemplate?(item: T, Wrapper: any): React.ComponentType<T> | JSX.Element;
41
+ valueTemplate?(item: T, Wrapper: React.ElementType): React.ComponentType<T> | JSX.Element;
41
42
  onChange(e: Array<T>): void;
42
43
  }
43
44
  interface IPropsSync<T> extends IPropsBase<T> {
44
45
  kind: 'synchronous';
45
46
  getOptions(): Array<ITreeNode<T>>;
46
47
  }
48
+ declare type ICancelFn = () => void;
47
49
  interface IPropsAsync<T> extends IPropsBase<T> {
48
50
  kind: 'asynchronous';
49
51
  getOptions?(): Array<ITreeNode<T>>;
50
- searchOptions(term: string, callback?: (options: Array<ITreeNode<T>>) => void): any;
52
+ searchOptions(term: string, callback?: (options: Array<ITreeNode<T>>) => void): ICancelFn;
51
53
  }
52
54
  declare type IProps<T> = IPropsSync<T> | IPropsAsync<T>;
53
55
  export interface ITreeNode<T> {
@@ -56,10 +58,16 @@ export interface ITreeNode<T> {
56
58
  }
57
59
  export declare class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
58
60
  private dropdownRef;
61
+ private ref;
62
+ private inputRef;
63
+ private categoryButtonRef;
59
64
  private openDropdownRef;
60
65
  private htmlId;
61
66
  private popperInstance;
62
67
  constructor(props: IProps<T>);
68
+ inputFocus: () => void;
69
+ listNavigation: () => void;
70
+ buttonFocus: () => void;
63
71
  componentDidMount: () => void;
64
72
  componentDidUpdate(prevProps: Readonly<IProps<T>>, prevState: Readonly<IState<T>>): void;
65
73
  toggleMenu(): void;
@@ -69,11 +77,11 @@ export declare class TreeSelect<T> extends React.Component<IProps<T>, IState<T>>
69
77
  handleValue(event: React.MouseEvent<HTMLLIElement, MouseEvent>, item: ITreeNode<T>): void;
70
78
  handleBranchValue(event: React.MouseEvent<HTMLButtonElement, MouseEvent>, item: ITreeNode<T>): void;
71
79
  handleTree(event: React.MouseEvent<HTMLLIElement, MouseEvent>, option: ITreeNode<T>): void;
72
- backButton: () => false | undefined;
80
+ backButton(): void;
73
81
  backButtonValue: () => void;
74
82
  recursion(arr: Array<ITreeNode<T>>): void;
75
83
  filteredItem(arr: Array<ITreeNode<T>>): JSX.Element | JSX.Element[] | undefined;
76
- banchButton(): JSX.Element;
84
+ branchButton(buttonValue: ITreeNode<T>): JSX.Element;
77
85
  private debounceFn;
78
86
  private ICancelFn;
79
87
  handleDebounce(): void;