superdesk-ui-framework 4.0.31 → 4.0.32

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.
@@ -825,7 +825,7 @@
825
825
  display: inline-block;
826
826
  margin-inline-end: var(--space--1);
827
827
  pointer-events: none;
828
- opacity: 0.4;
828
+ opacity: 0.4;
829
829
  z-index: 0;
830
830
  transition: opacity 0.2s ease;
831
831
  }
@@ -859,7 +859,7 @@
859
859
  -webkit-font-smoothing: antialiased;
860
860
  margin-inline-end: var(--space--1);
861
861
  pointer-events: none;
862
- opacity: 0.6;
862
+ opacity: 0.6;
863
863
  z-index: 0;
864
864
  transition: opacity 0.2s ease;
865
865
  }
@@ -959,6 +959,11 @@
959
959
  }
960
960
  }
961
961
 
962
+ .sd-input--content-width {
963
+ width: max-content;
964
+ min-width: 100px;
965
+ }
966
+
962
967
  .sd-input--invalid {
963
968
  .sd-input__input,
964
969
  .sd-input__select,
@@ -12,7 +12,13 @@ export interface IInputCommon {
12
12
  inlineLabel?: boolean;
13
13
  labelHidden?: boolean;
14
14
  tabindex?: number;
15
+
16
+ /**
17
+ * Defaults to `true`
18
+ * If set to false, it will be as wide as content
19
+ */
15
20
  fullWidth?: boolean;
21
+
16
22
  boxedStyle?: boolean;
17
23
  boxedLable?: boolean;
18
24
  }
@@ -44,11 +50,14 @@ export class InputWrapper extends React.Component<IPropsBase, IState> {
44
50
  }
45
51
 
46
52
  render() {
53
+ const fullWidth = this.props.fullWidth ?? true;
54
+
47
55
  const classes = classNames('sd-input', {
48
56
  'sd-input--inline-label': this.props.inlineLabel,
49
57
  'sd-input--required': this.props.required,
50
58
  'sd-input--disabled': this.props.disabled,
51
- 'sd-input--full-width': this.props.fullWidth,
59
+ 'sd-input--full-width': fullWidth,
60
+ 'sd-input--content-width': !fullWidth,
52
61
  'sd-input--invalid': this.props.invalid,
53
62
  'sd-input--medium': this.props.size === undefined,
54
63
  [`sd-input--${this.props.size}`]: this.props.size || this.props.size !== undefined,
@@ -54,7 +54,10 @@ interface IPropsBase<T> extends IInputWrapper {
54
54
  getBackgroundColor?(item: T): string;
55
55
  getBorderColor?(item: T): string;
56
56
  optionTemplate?(item: T): React.ComponentType<T> | JSX.Element;
57
- valueTemplate?(item: T, Wrapper: React.ElementType): React.ComponentType<T> | JSX.Element;
57
+ valueTemplate?(
58
+ item: T,
59
+ Wrapper: React.ComponentType<{backgroundColor?: string}>,
60
+ ): React.ComponentType<T> | JSX.Element;
58
61
  onChange(e: Array<T>): void;
59
62
  }
60
63
 
@@ -632,6 +635,24 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
632
635
  });
633
636
  }
634
637
 
638
+ private renderItemContent(item: T, Wrapper: React.ComponentType<{backgroundColor?: string}>) {
639
+ if (this.props.valueTemplate) {
640
+ return this.props.valueTemplate(item, Wrapper);
641
+ }
642
+
643
+ const content = this.props.optionTemplate?.(item) ?? (
644
+ <span>
645
+ {this.props.getLabel(item)}
646
+ </span>
647
+ );
648
+
649
+ return (
650
+ <Wrapper>
651
+ {content}
652
+ </Wrapper>
653
+ );
654
+ }
655
+
635
656
  render() {
636
657
  if (this.props.preview) {
637
658
  return (
@@ -702,7 +723,7 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
702
723
  labelHidden={this.props.labelHidden}
703
724
  htmlId={this.htmlId}
704
725
  tabindex={this.props.tabindex}
705
- fullWidth={this.props.inputWidth === '100%' ?? false}
726
+ fullWidth={this.props.fullWidth}
706
727
  data-test-id={this.props['data-test-id']}
707
728
  >
708
729
  <div
@@ -762,16 +783,7 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
762
783
 
763
784
  return (
764
785
  <ItemWrapper itemId={itemId} key={itemId} i={i}>
765
- {this.props.valueTemplate
766
- ? this.props.valueTemplate(item, Wrapper)
767
- : (
768
- <Wrapper>
769
- <span>
770
- {this.props.getLabel(item)}
771
- </span>
772
- </Wrapper>
773
- )
774
- }
786
+ {this.renderItemContent(item, Wrapper)}
775
787
  </ItemWrapper>
776
788
  );
777
789
  })}
@@ -863,14 +875,7 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
863
875
  );
864
876
 
865
877
  return <React.Fragment key={i}>
866
- {this.props.valueTemplate
867
- ? this.props.valueTemplate(item, Wrapper)
868
- : (
869
- <Wrapper>
870
- <span>{this.props.getLabel(item)}</span>
871
- </Wrapper>
872
- )
873
- }
878
+ {this.renderItemContent(item, Wrapper)}
874
879
  </React.Fragment>;
875
880
  })}
876
881
  </div>
@@ -886,6 +891,7 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
886
891
  style={{
887
892
  zIndex: this.zIndex,
888
893
  width: this.treeSelectRef.current?.offsetWidth,
894
+ minWidth: '300px',
889
895
  }}
890
896
  ref={this.dropdownRef}
891
897
  >
@@ -45093,12 +45093,14 @@ var InputWrapper = /** @class */ (function (_super) {
45093
45093
  }
45094
45094
  InputWrapper.prototype.render = function () {
45095
45095
  var _a;
45096
- var _b;
45096
+ var _b, _c;
45097
+ var fullWidth = (_b = this.props.fullWidth) !== null && _b !== void 0 ? _b : true;
45097
45098
  var classes = (0, classnames_1.default)('sd-input', (_a = {
45098
45099
  'sd-input--inline-label': this.props.inlineLabel,
45099
45100
  'sd-input--required': this.props.required,
45100
45101
  'sd-input--disabled': this.props.disabled,
45101
- 'sd-input--full-width': this.props.fullWidth,
45102
+ 'sd-input--full-width': fullWidth,
45103
+ 'sd-input--content-width': !fullWidth,
45102
45104
  'sd-input--invalid': this.props.invalid,
45103
45105
  'sd-input--medium': this.props.size === undefined
45104
45106
  },
@@ -45114,8 +45116,8 @@ var InputWrapper = /** @class */ (function (_super) {
45114
45116
  React.createElement("label", { className: labelClasses, htmlFor: this.props.htmlId, id: this.props.htmlId + 'label', tabIndex: this.props.tabindex === undefined ? undefined : -1 }, this.props.label),
45115
45117
  React.createElement("div", { className: "sd-input__input-container" }, this.props.children),
45116
45118
  this.props.maxLength
45117
- && React.createElement("div", { className: 'sd-input__char-count' }, (_b = this.props.value) === null || _b === void 0 ? void 0 :
45118
- _b.toString().length,
45119
+ && React.createElement("div", { className: 'sd-input__char-count' }, (_c = this.props.value) === null || _c === void 0 ? void 0 :
45120
+ _c.toString().length,
45119
45121
  " / ",
45120
45122
  this.props.maxLength),
45121
45123
  React.createElement("div", { className: 'sd-input__message-box' },
@@ -79480,9 +79482,17 @@ var TreeSelect = /** @class */ (function (_super) {
79480
79482
  value: (0, common_1.arrayMove)(this.state.value, result.source.index, result.destination.index),
79481
79483
  });
79482
79484
  };
79485
+ TreeSelect.prototype.renderItemContent = function (item, Wrapper) {
79486
+ var _a, _b, _c;
79487
+ if (this.props.valueTemplate) {
79488
+ return this.props.valueTemplate(item, Wrapper);
79489
+ }
79490
+ var content = (_c = (_b = (_a = this.props).optionTemplate) === null || _b === void 0 ? void 0 : _b.call(_a, item)) !== null && _c !== void 0 ? _c : (React.createElement("span", null, this.props.getLabel(item)));
79491
+ return (React.createElement(Wrapper, null, content));
79492
+ };
79483
79493
  TreeSelect.prototype.render = function () {
79484
79494
  var _this = this;
79485
- var _a, _b;
79495
+ var _a;
79486
79496
  if (this.props.preview) {
79487
79497
  return (React.createElement(SelectPreview_1.SelectPreview, { kind: this.props.allowMultiple
79488
79498
  ? {
@@ -79515,7 +79525,7 @@ var TreeSelect = /** @class */ (function (_super) {
79515
79525
  var children = _a.children;
79516
79526
  return React.createElement(React.Fragment, null, children);
79517
79527
  };
79518
- 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'] },
79528
+ 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: this.props.fullWidth, "data-test-id": this.props['data-test-id'] },
79519
79529
  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
79520
79530
  ? React.createElement("div", { className: "tags-input__tags" },
79521
79531
  this.props.readOnly
@@ -79535,10 +79545,7 @@ var TreeSelect = /** @class */ (function (_super) {
79535
79545
  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));
79536
79546
  };
79537
79547
  var itemId = _this.props.getId(item);
79538
- return (React.createElement(ItemWrapper, { itemId: itemId, key: itemId, i: i }, _this.props.valueTemplate
79539
- ? _this.props.valueTemplate(item, Wrapper)
79540
- : (React.createElement(Wrapper, null,
79541
- React.createElement("span", null, _this.props.getLabel(item))))));
79548
+ return (React.createElement(ItemWrapper, { itemId: itemId, key: itemId, i: i }, _this.renderItemContent(item, Wrapper)));
79542
79549
  })),
79543
79550
  this.state.value.length > 0
79544
79551
  ? (this.props.readOnly || this.props.disabled)
@@ -79571,16 +79578,14 @@ var TreeSelect = /** @class */ (function (_super) {
79571
79578
  (_this.props.readOnly !== true && _this.props.required !== true) && (React.createElement("span", { className: "tags-input__remove-button", "data-test-id": "clear-value" },
79572
79579
  React.createElement(Icon_1.Icon, { name: 'remove-sign' }))))));
79573
79580
  };
79574
- return React.createElement(React.Fragment, { key: i }, _this.props.valueTemplate
79575
- ? _this.props.valueTemplate(item, Wrapper)
79576
- : (React.createElement(Wrapper, null,
79577
- React.createElement("span", null, _this.props.getLabel(item)))));
79581
+ return React.createElement(React.Fragment, { key: i }, _this.renderItemContent(item, Wrapper));
79578
79582
  }))),
79579
79583
  React.createElement(WithPortal_1.WithPortal, { active: this.state.openDropdown, "data-test-id": "tree-select-popover" },
79580
79584
  React.createElement("div", { className: "autocomplete autocomplete--multi-select"
79581
79585
  + (this.props.width === 'medium' ? ' autocomplete--fixed-width' : ''), style: {
79582
79586
  zIndex: this.zIndex,
79583
- width: (_b = this.treeSelectRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth,
79587
+ width: (_a = this.treeSelectRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth,
79588
+ minWidth: '300px',
79584
79589
  }, ref: this.dropdownRef },
79585
79590
  React.createElement("div", { className: 'autocomplete__header' },
79586
79591
  React.createElement("div", { className: "autocomplete__icon" },
@@ -188153,7 +188158,7 @@ exports.ThreePaneLayoutPattern = ThreePaneLayoutPattern;
188153
188158
  /* 938 */
188154
188159
  /***/ (function(module, exports) {
188155
188160
 
188156
- module.exports = {"name":"superdesk-ui-framework","version":"4.0.31","license":"AGPL-3.0","repository":{"type":"git","url":"https://github.com/superdesk/superdesk-ui-framework.git"},"main":"dist/superdesk-ui.bundle.js","types":"react/index.d.ts","contributors":["Nemanja Pavlovic","Vladimir Stefanovic","Darko Tomic","Aleksandar Jelicic","Tomas Kikutis","Dragana Zivkovic"],"scripts":{"start":"webpack-dev-server --config tasks/webpack.dev.js","server":"webpack --watch --config tasks/webpack.prod.js && tsc-watch","build":"webpack --config tasks/webpack.prod.js && tsc","build-ui":"webpack && tsc && npm run lint","playground-lint":"tsc -p examples/pages/playgrounds/react-playgrounds --noEmit","lint":"eslint --parser=@typescript-eslint/parser app && tslint -c tslint.json 'app-typescript/**/*.{ts,tsx}' && npm run playground-lint","lint-fix":"tsc -p tsconfig.json --noEmit && tslint --fix -c tslint.json 'app-typescript/**/*.{ts,tsx}'","prepublishOnly":"npm run build","unit-test":"mocha","debug-unit-tests":"mocha --inspect-brk"},"devDependencies":{"@types/assert":"^1.5.6","@types/chart.js":"^2.9.24","@types/classnames":"^2.2.9","@types/enzyme":"^3.10.12","@types/enzyme-adapter-react-16":"^1.0.6","@types/lodash":"^4.14.161","@types/mocha":"^9.1.1","@types/react":"16.8.23","@types/react-beautiful-dnd":"^13.1.2","@types/react-dom":"16.8.0","@types/react-router-dom":"^5.1.2","@types/react-scrollspy":"^3.3.5","@typescript-eslint/parser":"^5.58.0","angular":"^1.7.9","angular-animate":"^1.7.9","angular-route":"^1.7.9","babel-core":"^6.26.0","babel-loader":"^7.1.2","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-preset-es2015":"^6.24.1","babel-preset-react":"^6.24.1","classnames":"^2.2.5","clean-webpack-plugin":"^1.0.0","code-prettify":"^0.1.0","copy-webpack-plugin":"^4.6.0","css-loader":"^2.1.1","enzyme":"^3.11.0","enzyme-adapter-react-16":"^1.15.7","eslint":"^4.6.1","eslint-loader":"^1.9.0","eslint-plugin-angular":"^3.1.1","eslint-plugin-react":"^7.3.0","extract-text-webpack-plugin":"^3.0.2","file-loader":"^0.11.2","html-loader":"^0.5.1","html-webpack-plugin":"^2.30.1","jquery":"^3.1.1","jquery-ui":"^1.12.1","jsdom":"20.0.3","jsdom-global":"3.0.2","lodash":"4.17.21","mocha":"^8.4.0","moment":"^2.29.3","node-sass":"6.0","prismjs":"^1.28.0","prop-types":"^15.6.0","react":"16.8.6","react-dom":"16.8.6","react-redux":"^5.0.6","react-router-dom":"^5.1.2","redux":"^3.7.2","redux-form":"^7.0.4","sass-loader":"^6.0.6","style-loader":"^0.18.2","superdesk-code-style":"^1.1.2","ts-loader":"^6.0.2","ts-node":"^10.9.1","tslint":"^5.18.0","typescript":"4.9.5","url-loader":"^1.1.2","webpack":"^3.5.5","webpack-cli":"3.3.10","webpack-dev-server":"2.11.1","webpack-merge":"^4.2.1"},"dependencies":{"@popperjs/core":"^2.4.0","@superdesk/common":"0.0.28","@superdesk/primereact":"^5.0.2-12","@superdesk/react-resizable-panels":"0.0.39","chart.js":"^2.9.3","date-fns":"2.7.0","popper-max-size-modifier":"^0.2.0","popper.js":"1.14.4","primeicons":"2.0.0","react-beautiful-dnd":"^13.0.0","react-id-generator":"^3.0.0","react-scrollspy":"^3.4.3","tippy.js":"^6.3.7"},"peerDependencies":{"moment":"*"},"volta":{"node":"14.21.3"}}
188161
+ module.exports = {"name":"superdesk-ui-framework","version":"4.0.32","license":"AGPL-3.0","repository":{"type":"git","url":"https://github.com/superdesk/superdesk-ui-framework.git"},"main":"dist/superdesk-ui.bundle.js","types":"react/index.d.ts","contributors":["Nemanja Pavlovic","Vladimir Stefanovic","Darko Tomic","Aleksandar Jelicic","Tomas Kikutis","Dragana Zivkovic"],"scripts":{"start":"webpack-dev-server --config tasks/webpack.dev.js","server":"webpack --watch --config tasks/webpack.prod.js && tsc-watch","build":"webpack --config tasks/webpack.prod.js && tsc","build-ui":"webpack && tsc && npm run lint","playground-lint":"tsc -p examples/pages/playgrounds/react-playgrounds --noEmit","lint":"eslint --parser=@typescript-eslint/parser app && tslint -c tslint.json 'app-typescript/**/*.{ts,tsx}' && npm run playground-lint","lint-fix":"tsc -p tsconfig.json --noEmit && tslint --fix -c tslint.json 'app-typescript/**/*.{ts,tsx}'","prepublishOnly":"npm run build","unit-test":"mocha","debug-unit-tests":"mocha --inspect-brk"},"devDependencies":{"@types/assert":"^1.5.6","@types/chart.js":"^2.9.24","@types/classnames":"^2.2.9","@types/enzyme":"^3.10.12","@types/enzyme-adapter-react-16":"^1.0.6","@types/lodash":"^4.14.161","@types/mocha":"^9.1.1","@types/react":"16.8.23","@types/react-beautiful-dnd":"^13.1.2","@types/react-dom":"16.8.0","@types/react-router-dom":"^5.1.2","@types/react-scrollspy":"^3.3.5","@typescript-eslint/parser":"^5.58.0","angular":"^1.7.9","angular-animate":"^1.7.9","angular-route":"^1.7.9","babel-core":"^6.26.0","babel-loader":"^7.1.2","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-preset-es2015":"^6.24.1","babel-preset-react":"^6.24.1","classnames":"^2.2.5","clean-webpack-plugin":"^1.0.0","code-prettify":"^0.1.0","copy-webpack-plugin":"^4.6.0","css-loader":"^2.1.1","enzyme":"^3.11.0","enzyme-adapter-react-16":"^1.15.7","eslint":"^4.6.1","eslint-loader":"^1.9.0","eslint-plugin-angular":"^3.1.1","eslint-plugin-react":"^7.3.0","extract-text-webpack-plugin":"^3.0.2","file-loader":"^0.11.2","html-loader":"^0.5.1","html-webpack-plugin":"^2.30.1","jquery":"^3.1.1","jquery-ui":"^1.12.1","jsdom":"20.0.3","jsdom-global":"3.0.2","lodash":"4.17.21","mocha":"^8.4.0","moment":"^2.29.3","node-sass":"6.0","prismjs":"^1.28.0","prop-types":"^15.6.0","react":"16.8.6","react-dom":"16.8.6","react-redux":"^5.0.6","react-router-dom":"^5.1.2","redux":"^3.7.2","redux-form":"^7.0.4","sass-loader":"^6.0.6","style-loader":"^0.18.2","superdesk-code-style":"^1.1.2","ts-loader":"^6.0.2","ts-node":"^10.9.1","tslint":"^5.18.0","typescript":"4.9.5","url-loader":"^1.1.2","webpack":"^3.5.5","webpack-cli":"3.3.10","webpack-dev-server":"2.11.1","webpack-merge":"^4.2.1"},"dependencies":{"@popperjs/core":"^2.4.0","@superdesk/common":"0.0.28","@superdesk/primereact":"^5.0.2-12","@superdesk/react-resizable-panels":"0.0.39","chart.js":"^2.9.3","date-fns":"2.7.0","popper-max-size-modifier":"^0.2.0","popper.js":"1.14.4","primeicons":"2.0.0","react-beautiful-dnd":"^13.0.0","react-id-generator":"^3.0.0","react-scrollspy":"^3.4.3","tippy.js":"^6.3.7"},"peerDependencies":{"moment":"*"},"volta":{"node":"14.21.3"}}
188157
188162
 
188158
188163
  /***/ }),
188159
188164
  /* 939 */
@@ -40346,6 +40346,10 @@ textarea.sd-media-carousel__media-title {
40346
40346
  inset-block-start: -2px;
40347
40347
  inset-inline-end: 4px; }
40348
40348
 
40349
+ .sd-input--content-width {
40350
+ width: max-content;
40351
+ min-width: 100px; }
40352
+
40349
40353
  .sd-input--invalid .sd-input__input,
40350
40354
  .sd-input--invalid .sd-input__select,
40351
40355
  .sd-input--invalid .sd-input__duration-input,
@@ -44597,12 +44597,14 @@ var InputWrapper = /** @class */ (function (_super) {
44597
44597
  }
44598
44598
  InputWrapper.prototype.render = function () {
44599
44599
  var _a;
44600
- var _b;
44600
+ var _b, _c;
44601
+ var fullWidth = (_b = this.props.fullWidth) !== null && _b !== void 0 ? _b : true;
44601
44602
  var classes = (0, classnames_1.default)('sd-input', (_a = {
44602
44603
  'sd-input--inline-label': this.props.inlineLabel,
44603
44604
  'sd-input--required': this.props.required,
44604
44605
  'sd-input--disabled': this.props.disabled,
44605
- 'sd-input--full-width': this.props.fullWidth,
44606
+ 'sd-input--full-width': fullWidth,
44607
+ 'sd-input--content-width': !fullWidth,
44606
44608
  'sd-input--invalid': this.props.invalid,
44607
44609
  'sd-input--medium': this.props.size === undefined
44608
44610
  },
@@ -44618,8 +44620,8 @@ var InputWrapper = /** @class */ (function (_super) {
44618
44620
  React.createElement("label", { className: labelClasses, htmlFor: this.props.htmlId, id: this.props.htmlId + 'label', tabIndex: this.props.tabindex === undefined ? undefined : -1 }, this.props.label),
44619
44621
  React.createElement("div", { className: "sd-input__input-container" }, this.props.children),
44620
44622
  this.props.maxLength
44621
- && React.createElement("div", { className: 'sd-input__char-count' }, (_b = this.props.value) === null || _b === void 0 ? void 0 :
44622
- _b.toString().length,
44623
+ && React.createElement("div", { className: 'sd-input__char-count' }, (_c = this.props.value) === null || _c === void 0 ? void 0 :
44624
+ _c.toString().length,
44623
44625
  " / ",
44624
44626
  this.props.maxLength),
44625
44627
  React.createElement("div", { className: 'sd-input__message-box' },
@@ -78601,9 +78603,17 @@ var TreeSelect = /** @class */ (function (_super) {
78601
78603
  value: (0, common_1.arrayMove)(this.state.value, result.source.index, result.destination.index),
78602
78604
  });
78603
78605
  };
78606
+ TreeSelect.prototype.renderItemContent = function (item, Wrapper) {
78607
+ var _a, _b, _c;
78608
+ if (this.props.valueTemplate) {
78609
+ return this.props.valueTemplate(item, Wrapper);
78610
+ }
78611
+ var content = (_c = (_b = (_a = this.props).optionTemplate) === null || _b === void 0 ? void 0 : _b.call(_a, item)) !== null && _c !== void 0 ? _c : (React.createElement("span", null, this.props.getLabel(item)));
78612
+ return (React.createElement(Wrapper, null, content));
78613
+ };
78604
78614
  TreeSelect.prototype.render = function () {
78605
78615
  var _this = this;
78606
- var _a, _b;
78616
+ var _a;
78607
78617
  if (this.props.preview) {
78608
78618
  return (React.createElement(SelectPreview_1.SelectPreview, { kind: this.props.allowMultiple
78609
78619
  ? {
@@ -78636,7 +78646,7 @@ var TreeSelect = /** @class */ (function (_super) {
78636
78646
  var children = _a.children;
78637
78647
  return React.createElement(React.Fragment, null, children);
78638
78648
  };
78639
- 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'] },
78649
+ 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: this.props.fullWidth, "data-test-id": this.props['data-test-id'] },
78640
78650
  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
78641
78651
  ? React.createElement("div", { className: "tags-input__tags" },
78642
78652
  this.props.readOnly
@@ -78656,10 +78666,7 @@ var TreeSelect = /** @class */ (function (_super) {
78656
78666
  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));
78657
78667
  };
78658
78668
  var itemId = _this.props.getId(item);
78659
- return (React.createElement(ItemWrapper, { itemId: itemId, key: itemId, i: i }, _this.props.valueTemplate
78660
- ? _this.props.valueTemplate(item, Wrapper)
78661
- : (React.createElement(Wrapper, null,
78662
- React.createElement("span", null, _this.props.getLabel(item))))));
78669
+ return (React.createElement(ItemWrapper, { itemId: itemId, key: itemId, i: i }, _this.renderItemContent(item, Wrapper)));
78663
78670
  })),
78664
78671
  this.state.value.length > 0
78665
78672
  ? (this.props.readOnly || this.props.disabled)
@@ -78692,16 +78699,14 @@ var TreeSelect = /** @class */ (function (_super) {
78692
78699
  (_this.props.readOnly !== true && _this.props.required !== true) && (React.createElement("span", { className: "tags-input__remove-button", "data-test-id": "clear-value" },
78693
78700
  React.createElement(Icon_1.Icon, { name: 'remove-sign' }))))));
78694
78701
  };
78695
- return React.createElement(React.Fragment, { key: i }, _this.props.valueTemplate
78696
- ? _this.props.valueTemplate(item, Wrapper)
78697
- : (React.createElement(Wrapper, null,
78698
- React.createElement("span", null, _this.props.getLabel(item)))));
78702
+ return React.createElement(React.Fragment, { key: i }, _this.renderItemContent(item, Wrapper));
78699
78703
  }))),
78700
78704
  React.createElement(WithPortal_1.WithPortal, { active: this.state.openDropdown, "data-test-id": "tree-select-popover" },
78701
78705
  React.createElement("div", { className: "autocomplete autocomplete--multi-select"
78702
78706
  + (this.props.width === 'medium' ? ' autocomplete--fixed-width' : ''), style: {
78703
78707
  zIndex: this.zIndex,
78704
- width: (_b = this.treeSelectRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth,
78708
+ width: (_a = this.treeSelectRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth,
78709
+ minWidth: '300px',
78705
78710
  }, ref: this.dropdownRef },
78706
78711
  React.createElement("div", { className: 'autocomplete__header' },
78707
78712
  React.createElement("div", { className: "autocomplete__icon" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "superdesk-ui-framework",
3
- "version": "4.0.31",
3
+ "version": "4.0.32",
4
4
  "license": "AGPL-3.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,6 +10,10 @@ export interface IInputCommon {
10
10
  inlineLabel?: boolean;
11
11
  labelHidden?: boolean;
12
12
  tabindex?: number;
13
+ /**
14
+ * Defaults to `true`
15
+ * If set to false, it will be as wide as content
16
+ */
13
17
  fullWidth?: boolean;
14
18
  boxedStyle?: boolean;
15
19
  boxedLable?: boolean;
@@ -57,12 +57,14 @@ var InputWrapper = /** @class */ (function (_super) {
57
57
  }
58
58
  InputWrapper.prototype.render = function () {
59
59
  var _a;
60
- var _b;
60
+ var _b, _c;
61
+ var fullWidth = (_b = this.props.fullWidth) !== null && _b !== void 0 ? _b : true;
61
62
  var classes = (0, classnames_1.default)('sd-input', (_a = {
62
63
  'sd-input--inline-label': this.props.inlineLabel,
63
64
  'sd-input--required': this.props.required,
64
65
  'sd-input--disabled': this.props.disabled,
65
- 'sd-input--full-width': this.props.fullWidth,
66
+ 'sd-input--full-width': fullWidth,
67
+ 'sd-input--content-width': !fullWidth,
66
68
  'sd-input--invalid': this.props.invalid,
67
69
  'sd-input--medium': this.props.size === undefined
68
70
  },
@@ -78,8 +80,8 @@ var InputWrapper = /** @class */ (function (_super) {
78
80
  React.createElement("label", { className: labelClasses, htmlFor: this.props.htmlId, id: this.props.htmlId + 'label', tabIndex: this.props.tabindex === undefined ? undefined : -1 }, this.props.label),
79
81
  React.createElement("div", { className: "sd-input__input-container" }, this.props.children),
80
82
  this.props.maxLength
81
- && React.createElement("div", { className: 'sd-input__char-count' }, (_b = this.props.value) === null || _b === void 0 ? void 0 :
82
- _b.toString().length,
83
+ && React.createElement("div", { className: 'sd-input__char-count' }, (_c = this.props.value) === null || _c === void 0 ? void 0 :
84
+ _c.toString().length,
83
85
  " / ",
84
86
  this.props.maxLength),
85
87
  React.createElement("div", { className: 'sd-input__message-box' },
@@ -35,7 +35,9 @@ interface IPropsBase<T> extends IInputWrapper {
35
35
  getBackgroundColor?(item: T): string;
36
36
  getBorderColor?(item: T): string;
37
37
  optionTemplate?(item: T): React.ComponentType<T> | JSX.Element;
38
- valueTemplate?(item: T, Wrapper: React.ElementType): React.ComponentType<T> | JSX.Element;
38
+ valueTemplate?(item: T, Wrapper: React.ComponentType<{
39
+ backgroundColor?: string;
40
+ }>): React.ComponentType<T> | JSX.Element;
39
41
  onChange(e: Array<T>): void;
40
42
  }
41
43
  interface IPropsSync<T> extends IPropsBase<T> {
@@ -89,6 +91,7 @@ export declare class TreeSelect<T> extends React.Component<IProps<T>, IState<T>>
89
91
  private ICancelFn;
90
92
  handleDebounce(): void;
91
93
  onDragEnd(result: DropResult): void;
94
+ private renderItemContent;
92
95
  render(): JSX.Element;
93
96
  }
94
97
  export {};
@@ -527,9 +527,17 @@ var TreeSelect = /** @class */ (function (_super) {
527
527
  value: (0, common_1.arrayMove)(this.state.value, result.source.index, result.destination.index),
528
528
  });
529
529
  };
530
+ TreeSelect.prototype.renderItemContent = function (item, Wrapper) {
531
+ var _a, _b, _c;
532
+ if (this.props.valueTemplate) {
533
+ return this.props.valueTemplate(item, Wrapper);
534
+ }
535
+ var content = (_c = (_b = (_a = this.props).optionTemplate) === null || _b === void 0 ? void 0 : _b.call(_a, item)) !== null && _c !== void 0 ? _c : (React.createElement("span", null, this.props.getLabel(item)));
536
+ return (React.createElement(Wrapper, null, content));
537
+ };
530
538
  TreeSelect.prototype.render = function () {
531
539
  var _this = this;
532
- var _a, _b;
540
+ var _a;
533
541
  if (this.props.preview) {
534
542
  return (React.createElement(SelectPreview_1.SelectPreview, { kind: this.props.allowMultiple
535
543
  ? {
@@ -562,7 +570,7 @@ var TreeSelect = /** @class */ (function (_super) {
562
570
  var children = _a.children;
563
571
  return React.createElement(React.Fragment, null, children);
564
572
  };
565
- 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'] },
573
+ 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: this.props.fullWidth, "data-test-id": this.props['data-test-id'] },
566
574
  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
567
575
  ? React.createElement("div", { className: "tags-input__tags" },
568
576
  this.props.readOnly
@@ -582,10 +590,7 @@ var TreeSelect = /** @class */ (function (_super) {
582
590
  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));
583
591
  };
584
592
  var itemId = _this.props.getId(item);
585
- return (React.createElement(ItemWrapper, { itemId: itemId, key: itemId, i: i }, _this.props.valueTemplate
586
- ? _this.props.valueTemplate(item, Wrapper)
587
- : (React.createElement(Wrapper, null,
588
- React.createElement("span", null, _this.props.getLabel(item))))));
593
+ return (React.createElement(ItemWrapper, { itemId: itemId, key: itemId, i: i }, _this.renderItemContent(item, Wrapper)));
589
594
  })),
590
595
  this.state.value.length > 0
591
596
  ? (this.props.readOnly || this.props.disabled)
@@ -618,16 +623,14 @@ var TreeSelect = /** @class */ (function (_super) {
618
623
  (_this.props.readOnly !== true && _this.props.required !== true) && (React.createElement("span", { className: "tags-input__remove-button", "data-test-id": "clear-value" },
619
624
  React.createElement(Icon_1.Icon, { name: 'remove-sign' }))))));
620
625
  };
621
- return React.createElement(React.Fragment, { key: i }, _this.props.valueTemplate
622
- ? _this.props.valueTemplate(item, Wrapper)
623
- : (React.createElement(Wrapper, null,
624
- React.createElement("span", null, _this.props.getLabel(item)))));
626
+ return React.createElement(React.Fragment, { key: i }, _this.renderItemContent(item, Wrapper));
625
627
  }))),
626
628
  React.createElement(WithPortal_1.WithPortal, { active: this.state.openDropdown, "data-test-id": "tree-select-popover" },
627
629
  React.createElement("div", { className: "autocomplete autocomplete--multi-select"
628
630
  + (this.props.width === 'medium' ? ' autocomplete--fixed-width' : ''), style: {
629
631
  zIndex: this.zIndex,
630
- width: (_b = this.treeSelectRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth,
632
+ width: (_a = this.treeSelectRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth,
633
+ minWidth: '300px',
631
634
  }, ref: this.dropdownRef },
632
635
  React.createElement("div", { className: 'autocomplete__header' },
633
636
  React.createElement("div", { className: "autocomplete__icon" },