superdesk-ui-framework 3.0.5 → 3.0.7

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.
@@ -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.5",
3
+ "version": "3.0.7",
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",
@@ -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));
@@ -11,12 +11,11 @@ export interface ISideBarTab {
11
11
  size: 'small' | 'big';
12
12
  tooltip?: string;
13
13
  badgeValue?: string;
14
- onClick(event: React.MouseEvent<HTMLAnchorElement, MouseEvent>): void;
15
14
  }
16
15
  export declare class SideBarTabs extends React.PureComponent<IProps> {
17
16
  constructor(props: IProps);
18
17
  componentDidMount(): void;
19
- handleClick(item: ISideBarTab, event: React.MouseEvent<HTMLAnchorElement, MouseEvent>): void;
18
+ handleClick(item: ISideBarTab): void;
20
19
  render(): JSX.Element;
21
20
  }
22
21
  export {};
@@ -56,13 +56,12 @@ var SideBarTabs = /** @class */ (function (_super) {
56
56
  this.props.onActiveTabChange(activeItem.id);
57
57
  }
58
58
  };
59
- SideBarTabs.prototype.handleClick = function (item, event) {
59
+ SideBarTabs.prototype.handleClick = function (item) {
60
60
  if (this.props.activeTab === item.id) {
61
61
  this.props.onActiveTabChange(null);
62
62
  }
63
63
  else {
64
64
  this.props.onActiveTabChange(item.id);
65
- item.onClick(event);
66
65
  }
67
66
  };
68
67
  SideBarTabs.prototype.render = function () {
@@ -74,7 +73,7 @@ var SideBarTabs = /** @class */ (function (_super) {
74
73
  }
75
74
  else {
76
75
  return (React.createElement("li", { key: index, "data-sd-tooltip": item.tooltip, "data-flow": 'left' },
77
- React.createElement("a", { role: 'button', "aria-label": item.tooltip, className: (0, classnames_1.default)('sd-sidetab-menu__btn', { 'sd-sidetab-menu__btn--active': item.id === _this.props.activeTab }), onClick: function (event) { return _this.handleClick(item, event); } },
76
+ React.createElement("a", { role: 'button', "aria-label": item.tooltip, className: (0, classnames_1.default)('sd-sidetab-menu__btn', { 'sd-sidetab-menu__btn--active': item.id === _this.props.activeTab }), onClick: function () { return _this.handleClick(item); } },
78
77
  item.badgeValue != null && (React.createElement(Badge_1.Badge, { text: item['badgeValue'], type: 'primary' })),
79
78
  React.createElement("span", { className: 'sd-sidetab-menu__main-icon ' },
80
79
  React.createElement(Icon_1.Icon, { size: item['size'], name: item['icon'] })),
@@ -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;