superdesk-ui-framework 4.0.14 → 4.0.16

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.
@@ -31,7 +31,7 @@ export default class TooltipDoc extends React.Component {
31
31
  </Tooltip>
32
32
  <Tooltip text="Right on!" flow='right'>
33
33
  <Button text='right' onClick={() => false} />
34
- </Tooltip>
34
+ </Tooltip>
35
35
  </div>
36
36
  </Markup.ReactMarkupPreview>
37
37
  <Markup.ReactMarkupCode>{`
@@ -51,53 +51,10 @@ export default class TooltipDoc extends React.Component {
51
51
  </Markup.ReactMarkupCode>
52
52
  </Markup.ReactMarkup>
53
53
 
54
- <h3 className="docs-page__h3">Appended to body</h3>
55
- <p className="docs-page__paragraph">
56
- Appends tooltip element to body therefore avoids overflow issues. For performance reasons don't use it if not necessary.
57
- </p>
58
- <Markup.ReactMarkup>
59
- <Markup.ReactMarkupPreview>
60
-
61
- <div className="docs-page__content-row docs-page__content-row--no-margin">
62
-
63
- <div className="docs-page__content-row docs-page__content-row--no-margin">
64
- <Tooltip text="I'm appended to body" flow='top' appendToBody={true}>
65
- <Button text='top' onClick={() => false} />
66
- </Tooltip>
67
- <Tooltip text="I'm appended to body" flow='down' appendToBody={true}>
68
- <Button text='Down' onClick={() => false} />
69
- </Tooltip>
70
- <Tooltip text="I'm appended to body" flow='left' appendToBody={true}>
71
- <Button text='left' onClick={() => false} />
72
- </Tooltip>
73
- <Tooltip text="I'm appended to body" flow='right' appendToBody={true}>
74
- <Button text='right' onClick={() => false} />
75
- </Tooltip>
76
- </div>
77
- </div>
78
- </Markup.ReactMarkupPreview>
79
- <Markup.ReactMarkupCode>{`
80
- <Tooltip text="I'm appended to body" flow='top' appendToBody={true}>
81
- <Button text='top' onClick={() => false} />
82
- </Tooltip>
83
- <Tooltip text="I'm appended to body" flow='down' appendToBody={true}>
84
- <Button text='Down' onClick={() => false} />
85
- </Tooltip>
86
- <Tooltip text="I'm appended to body" flow='left' appendToBody={true}>
87
- <Button text='left' onClick={() => false} />
88
- </Tooltip>
89
- <Tooltip text="I'm appended to body" flow='right' appendToBody={true}>
90
- <Button text='right' onClick={() => false} />
91
- </Tooltip>
92
- `}
93
- </Markup.ReactMarkupCode>
94
- </Markup.ReactMarkup>
95
-
96
54
  <h3 className="docs-page__h3">Props</h3>
97
55
  <PropsList>
98
56
  <Prop name='text' isRequired={true} type='string' default='/' description='Tooltip text value.' />
99
57
  <Prop name='flow' isRequired={false} type='top | left | right | down' default='top' description='Position of tooltip text.' />
100
- <Prop name='appendToBody' isRequired={false} type='boolean' default='false' description='Appends element to body therefore avoids overflow issues.' />
101
58
  </PropsList>
102
59
  </section>
103
60
  )
@@ -146,7 +146,7 @@ export class RundownEditor extends React.Component<IProps, IState> {
146
146
  <Layout.LayoutContainer>
147
147
  <Layout.HeaderPanel>
148
148
  <SubNav>
149
- <Tooltip text={this.state.isExpanded ? "Revert Authoring" : "Expand Authoring"} flow='right' appendToBody={true}>
149
+ <Tooltip text={this.state.isExpanded ? "Revert Authoring" : "Expand Authoring"} flow='right'>
150
150
  <button
151
151
  className={`expand-button ${this.state.isExpanded ? "expand-button--expanded" : ""}`}
152
152
  onClick={this.toggleExpand}
@@ -221,7 +221,7 @@ export class TestGround extends React.Component<IProps, IState> {
221
221
  </div>
222
222
  <div className="sd-list-item__action-menu sd-list-item__action-menu--direction-row ps-0">
223
223
  <ButtonGroup orientation='vertical' spaces='compact'>
224
- <IconButton size='small' icon='external' ariaValue='Open in modal' onClick={()=> false} />
224
+ <IconButton size='small' icon='external' ariaValue='Open in modal' onClick={()=> false} />
225
225
  <IconButton size='small' icon='trash' ariaValue='Delete Coverage' onClick={()=> false} />
226
226
  </ButtonGroup>
227
227
  </div>
@@ -378,7 +378,7 @@ export class TestGround extends React.Component<IProps, IState> {
378
378
  <div className='sd-border--medium border-dashed p-1-5 radius-md d-flex items-center justify-center'>
379
379
  <span className='text-sm text-color-subdued'>No Coverages yet</span>
380
380
  </div>
381
-
381
+
382
382
  {/* <ContentDivider type="dashed" margin='x-small' /> */}
383
383
 
384
384
  {/* NESTED BOX */}
@@ -404,7 +404,7 @@ export class TestGround extends React.Component<IProps, IState> {
404
404
  <span className="sd-list-item__text-light">//</span>
405
405
  <span className="sd-list-item__text">Archive</span>
406
406
  </span>
407
-
407
+
408
408
  </span>
409
409
  <time className="sd-margin-s--auto" title="June 01, 2022 11:08 AM">11:08, 01.06.2022</time>
410
410
  </div>
@@ -460,8 +460,8 @@ export class TestGround extends React.Component<IProps, IState> {
460
460
  <span className="sd-list-item__text-light">//</span>
461
461
  <span className="sd-list-item__text">Archive</span>
462
462
  </span>
463
-
464
-
463
+
464
+
465
465
  </span>
466
466
  <Label text='Draft' style='translucent' type='default' />
467
467
  </div>
@@ -662,7 +662,7 @@ export class TestGround extends React.Component<IProps, IState> {
662
662
 
663
663
  <hr />
664
664
 
665
- <Avatar
665
+ <Avatar
666
666
  displayName="Jeffrey Lebowski"
667
667
  imageUrl={null}
668
668
  initials='JL'
@@ -757,7 +757,7 @@ export class TestGround extends React.Component<IProps, IState> {
757
757
  <span className="sd-list-item__text-light">//</span>
758
758
  <span className="sd-list-item__text">Archive</span>
759
759
  </span>
760
-
760
+
761
761
  </span>
762
762
  <time className="sd-margin-s--auto" title="June 01, 2022 11:08 AM">11:08, 01.06.2022</time>
763
763
  </div>
@@ -881,8 +881,8 @@ export class TestGround extends React.Component<IProps, IState> {
881
881
  <hr />
882
882
 
883
883
  <SubNav color='darker'>
884
- <Tooltip text={this.state.isExpanded ? "Revert Authoring" : "Expand Authoring"} flow='right' appendToBody={true}>
885
- <button
884
+ <Tooltip text={this.state.isExpanded ? "Revert Authoring" : "Expand Authoring"} flow='right'>
885
+ <button
886
886
  className={`expand-button ${this.state.isExpanded ? "expand-button--expanded" : ""}`}
887
887
  onClick={this.toggleExpand}
888
888
  >
@@ -911,11 +911,11 @@ export class TestGround extends React.Component<IProps, IState> {
911
911
  </ButtonGroup>
912
912
  </ButtonGroup>
913
913
  </SubNav>
914
-
914
+
915
915
  <hr />
916
916
 
917
917
  <div className='sd-grid-list sd-grid-list--xx-small sd-grid-list--gap-s sd-grid-list--no-margin' style={{width:'290px'}}>
918
-
918
+
919
919
  <IllustrationButton text='Headlines' onClick={()=> false}>
920
920
  <SvgIconIllustration illustration='headlines' />
921
921
  </IllustrationButton>
@@ -997,16 +997,16 @@ export class TestGround extends React.Component<IProps, IState> {
997
997
  </span>
998
998
  <Icon name='chevron-down-thin' />
999
999
  </button> */}
1000
-
1000
+
1001
1001
  <hr />
1002
1002
 
1003
1003
  <Button text="Planning Templates" onClick={() => this.setState({modalPlanningTemplates: true})} />
1004
1004
  <span></span>
1005
-
1006
-
1005
+
1006
+
1007
1007
  {/* Event Saving modals */}
1008
1008
  {/* Event Only (This one existed Before) */}
1009
- <Modal
1009
+ <Modal
1010
1010
  headerTemplate="Save Event"
1011
1011
  visible={this.state.modalSaveEvent}
1012
1012
  contentPadding='medium'
@@ -1056,7 +1056,7 @@ export class TestGround extends React.Component<IProps, IState> {
1056
1056
  </Modal>
1057
1057
 
1058
1058
  {/* Event and Planning */}
1059
- <Modal
1059
+ <Modal
1060
1060
  headerTemplate="Save Event"
1061
1061
  visible={this.state.modalSaveEvent2}
1062
1062
  contentPadding='medium'
@@ -1154,7 +1154,7 @@ export class TestGround extends React.Component<IProps, IState> {
1154
1154
  </Modal>
1155
1155
 
1156
1156
  {/* Planning only */}
1157
- <Modal
1157
+ <Modal
1158
1158
  headerTemplate="Save Event"
1159
1159
  visible={this.state.modalSaveEvent3}
1160
1160
  contentPadding='medium'
@@ -1373,7 +1373,7 @@ export class TestGround extends React.Component<IProps, IState> {
1373
1373
 
1374
1374
  <img
1375
1375
  src="/path/toimage"
1376
- alt="my image"
1376
+ alt="my image"
1377
1377
  onError={({ currentTarget }) => {
1378
1378
  currentTarget.onerror = null; // prevents looping
1379
1379
  currentTarget.src="/illustration--playground.svg";
@@ -1417,7 +1417,7 @@ export class TestGround extends React.Component<IProps, IState> {
1417
1417
  labelHidden={true}
1418
1418
  type='text'
1419
1419
  />
1420
-
1420
+
1421
1421
  <hr />
1422
1422
 
1423
1423
  <div className='form__group-new'>
@@ -1776,7 +1776,7 @@ export class TestGround extends React.Component<IProps, IState> {
1776
1776
  </div>
1777
1777
 
1778
1778
  <div className='table-list__add-bar-container'>
1779
- <Tooltip text='Add item' flow='top' appendToBody={true}>
1779
+ <Tooltip text='Add item' flow='top'>
1780
1780
  <div className='table-list__add-bar'>
1781
1781
  <Button type="primary" icon="plus-large" text="Add item" size="small" shape="round" iconOnly={true} onClick={()=> false} />
1782
1782
  </div>
@@ -1804,7 +1804,7 @@ export class TestGround extends React.Component<IProps, IState> {
1804
1804
  </div>
1805
1805
 
1806
1806
  <div className='table-list__add-bar-container'>
1807
- <Tooltip text='Add item' flow='top' appendToBody={true}>
1807
+ <Tooltip text='Add item' flow='top'>
1808
1808
  <div className='table-list__add-bar'>
1809
1809
  <Button type="primary" icon="plus-large" text="Add item" size="small" shape="round" iconOnly={true} onClick={()=> false} />
1810
1810
  </div>
@@ -1833,7 +1833,7 @@ export class TestGround extends React.Component<IProps, IState> {
1833
1833
  </div>
1834
1834
 
1835
1835
  <div className='table-list__add-bar-container'>
1836
- <Tooltip text='Add item' flow='top' appendToBody={true}>
1836
+ <Tooltip text='Add item' flow='top'>
1837
1837
  <div className='table-list__add-bar'>
1838
1838
  <Button type="primary" icon="plus-large" text="Add item" size="small" shape="round" iconOnly={true} onClick={()=> false} />
1839
1839
  </div>
@@ -1861,7 +1861,7 @@ export class TestGround extends React.Component<IProps, IState> {
1861
1861
  <hr />
1862
1862
 
1863
1863
  <Checkbox label={{text: 'The label is hidden here', hidden: true}} onChange={(value) => console.log('value changed', value)} />
1864
-
1864
+
1865
1865
  <hr />
1866
1866
 
1867
1867
  <div className="sd-check-button__group sd-check-button__group--start">
@@ -1974,9 +1974,9 @@ export class TestGround extends React.Component<IProps, IState> {
1974
1974
  </ul>
1975
1975
  </div>
1976
1976
  <div className="sd-thumb-carousel__description">
1977
- Nulla vitae elit libero, a pharetra augue. Nulla vitae elit libero, a pharetra augue.
1978
- Donec id elit non mi porta gravida at eget metus. Etiam porta sem malesuada magna mollis euismod.
1979
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cum sociis natoque penatibus et magnis dis
1977
+ Nulla vitae elit libero, a pharetra augue. Nulla vitae elit libero, a pharetra augue.
1978
+ Donec id elit non mi porta gravida at eget metus. Etiam porta sem malesuada magna mollis euismod.
1979
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cum sociis natoque penatibus et magnis dis
1980
1980
  parturient montes, nascetur ridiculus mus.
1981
1981
  </div>
1982
1982
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "superdesk-ui-framework",
3
- "version": "4.0.14",
3
+ "version": "4.0.16",
4
4
  "license": "AGPL-3.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -106,7 +106,8 @@
106
106
  "primeicons": "2.0.0",
107
107
  "react-beautiful-dnd": "^13.0.0",
108
108
  "react-id-generator": "^3.0.0",
109
- "react-scrollspy": "^3.4.3"
109
+ "react-scrollspy": "^3.4.3",
110
+ "tippy.js": "^6.3.7"
110
111
  },
111
112
  "peerDependencies": {
112
113
  "moment": "*"
@@ -59,7 +59,7 @@ var CreateButton = /** @class */ (function (_super) {
59
59
  _a["sd-navbtn--".concat(this.props.type)] = this.props.type,
60
60
  _a));
61
61
  var value = this.props.value === undefined ? 'button' : this.props.value;
62
- return (React.createElement(Tooltip_1.Tooltip, { text: this.props.ariaValue, flow: this.props.toolTipFlow, appendToBody: true },
62
+ return (React.createElement(Tooltip_1.Tooltip, { text: this.props.ariaValue, flow: this.props.toolTipFlow },
63
63
  React.createElement("button", { type: value, className: classes, tabIndex: 0, onClick: this.props.onClick, "aria-label": this.props.ariaValue, id: this.props.id },
64
64
  React.createElement(Icon_1.Icon, { name: "plus-large" }),
65
65
  React.createElement("span", { className: "circle" }))));
@@ -79,13 +79,15 @@ var DateTimePicker = /** @class */ (function (_super) {
79
79
  ? "".concat(this.prepareFormat(this.props.value.getHours()), ":").concat(this.prepareFormat(this.props.value.getMinutes()))
80
80
  : '';
81
81
  return (React.createElement("div", { style: { width: this.props.width ? this.props.width : MIN_WIDTH } },
82
- React.createElement(common_1.Spacer, { h: true, gap: "8", alignItems: 'end' },
83
- React.createElement(DatePicker_1.DatePicker, { disabled: this.props.disabled, preview: this.props.preview, required: this.props.required, hideClearButton: true, value: this.props.value, onChange: function (val) {
84
- _this.handleDateChange(val);
85
- }, dateFormat: this.props.dateFormat, label: this.props.label.text, inlineLabel: (_a = this.props.label.hidden) !== null && _a !== void 0 ? _a : false, labelHidden: (_b = this.props.label.hidden) !== null && _b !== void 0 ? _b : false, fullWidth: this.props.fullWidth }),
86
- React.createElement(TimePicker_1.TimePicker, { disabled: this.props.disabled, preview: this.props.preview, value: convertedTimeValue, onChange: function (val) {
87
- _this.handleTimeChange(val);
88
- }, inlineLabel: true, labelHidden: true, allowSeconds: this.props.allowSeconds, fullWidth: this.props.fullWidth, required: this.props.required }),
82
+ React.createElement(common_1.Spacer, { h: true, gap: "8", alignItems: 'end', noWrap: true },
83
+ React.createElement("div", { style: { flexGrow: 1 } },
84
+ React.createElement(DatePicker_1.DatePicker, { disabled: this.props.disabled, preview: this.props.preview, required: this.props.required, hideClearButton: true, value: this.props.value, onChange: function (val) {
85
+ _this.handleDateChange(val);
86
+ }, dateFormat: this.props.dateFormat, label: this.props.label.text, inlineLabel: (_a = this.props.label.hidden) !== null && _a !== void 0 ? _a : false, labelHidden: (_b = this.props.label.hidden) !== null && _b !== void 0 ? _b : false, fullWidth: this.props.fullWidth })),
87
+ React.createElement("div", { style: { flexGrow: 1 } },
88
+ React.createElement(TimePicker_1.TimePicker, { disabled: this.props.disabled, preview: this.props.preview, value: convertedTimeValue, onChange: function (val) {
89
+ _this.handleTimeChange(val);
90
+ }, inlineLabel: true, labelHidden: true, allowSeconds: this.props.allowSeconds, fullWidth: this.props.fullWidth, required: this.props.required })),
89
91
  this.props.preview !== true && (React.createElement(IconButton_1.IconButton, { disabled: this.props.disabled, icon: 'remove-sign', onClick: function () {
90
92
  _this.props.onChange(null);
91
93
  }, ariaValue: 'Clear' })))));
@@ -58,7 +58,7 @@ var IconButton = /** @class */ (function (_super) {
58
58
  _a["icn-btn--".concat(this.props.style)] = this.props.style || this.props.style !== undefined,
59
59
  _a['icn-btn--disabled'] = this.props.disabled,
60
60
  _a));
61
- return (React.createElement(Tooltip_1.Tooltip, { text: this.props.ariaValue, flow: this.props.toolTipFlow, appendToBody: this.props.toolTipAppend, disabled: this.props.disabled },
61
+ return (React.createElement(Tooltip_1.Tooltip, { text: this.props.disabled ? null : this.props.ariaValue, flow: this.props.toolTipFlow },
62
62
  React.createElement("button", { id: this.props.id, tabIndex: 0, onClick: this.props.onClick, className: classes, disabled: this.props.disabled, "aria-label": this.props.ariaValue },
63
63
  React.createElement(Icon_1.Icon, { name: this.props.icon, ariaHidden: true }))));
64
64
  };
@@ -137,7 +137,7 @@ var TableList = /** @class */ (function (_super) {
137
137
  provided.placeholder,
138
138
  (_this.props.addItem && !_this.props.readOnly)
139
139
  && React.createElement("div", { className: "table-list__add-item table-list__item--margin" },
140
- React.createElement(Tooltip_1.Tooltip, { text: 'Add item', flow: 'top', appendToBody: true },
140
+ React.createElement(Tooltip_1.Tooltip, { text: 'Add item', flow: 'top' },
141
141
  React.createElement("div", { className: 'table-list__add-item--container sd-margin-x--auto' }, _this.dropDown()))))); }))
142
142
  : React.createElement("div", { role: 'list', className: classes },
143
143
  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, selected: item.selected, onClick: item.onClick
@@ -150,12 +150,12 @@ var TableList = /** @class */ (function (_super) {
150
150
  && _this.props.onAddItem(index, item); } })); }),
151
151
  (this.props.addItem && !this.props.readOnly)
152
152
  && React.createElement("div", { className: "table-list__add-item table-list__item--margin" },
153
- React.createElement(Tooltip_1.Tooltip, { text: 'Add item', flow: 'top', appendToBody: true },
153
+ React.createElement(Tooltip_1.Tooltip, { text: 'Add item', flow: 'top' },
154
154
  React.createElement("div", { className: 'table-list__add-item--container sd-margin-x--auto' }, this.dropDown()))))
155
155
  : (this.props.addItem && !this.props.readOnly)
156
156
  ? React.createElement("div", { role: 'list', className: classes },
157
157
  React.createElement("div", { className: "table-list__add-item table-list__item--margin" },
158
- React.createElement(Tooltip_1.Tooltip, { text: 'Add item', flow: 'top', appendToBody: true },
158
+ React.createElement(Tooltip_1.Tooltip, { text: 'Add item', flow: 'top' },
159
159
  React.createElement("div", { className: 'table-list__add-item--container sd-margin-x--auto' }, this.dropDown()))))
160
160
  : null);
161
161
  };
@@ -225,7 +225,7 @@ var TableListItem = /** @class */ (function (_super) {
225
225
  && React.createElement("div", { className: 'table-list__slide-in-actions', onClick: this.onActionMenuClick }, this.props.action)),
226
226
  this.props.addItem
227
227
  && React.createElement("div", { className: 'table-list__add-bar-container' },
228
- React.createElement(Tooltip_1.Tooltip, { text: 'Add item', flow: 'top', appendToBody: true },
228
+ React.createElement(Tooltip_1.Tooltip, { text: 'Add item', flow: 'top' },
229
229
  React.createElement("div", { className: 'table-list__add-bar' },
230
230
  React.createElement(Dropdown_1.Dropdown, { onChange: this.props.onAddItem, items: this.props.itemsDropdown ? this.props.itemsDropdown() : [] },
231
231
  React.createElement(Button_1.Button, { type: "primary", icon: "plus-large", text: "Add item", size: "small", shape: "round", iconOnly: true, onClick: function () { return false; } }))))))));
@@ -69,7 +69,7 @@ var Switch = /** @class */ (function (_super) {
69
69
  React.createElement("span", { className: "inner" })));
70
70
  // if external label is used it can't be hidden
71
71
  if (this.props.label.hidden && typeof this.props.label.content === 'string') {
72
- return (React.createElement(Tooltip_1.Tooltip, { text: this.props.label.content, flow: this.props.toolTipFlow, appendToBody: this.props.toolTipAppend },
72
+ return (React.createElement(Tooltip_1.Tooltip, { text: this.props.label.content, flow: this.props.toolTipFlow },
73
73
  React.createElement("span", { className: "sd-switch__wrapper", tabIndex: -1 },
74
74
  checkboxInput,
75
75
  React.createElement("label", { className: 'a11y-only', htmlFor: this.htmlId }, this.props.label.content))));
@@ -1,9 +1,15 @@
1
1
  import * as React from 'react';
2
2
  interface IProps {
3
- text: string;
3
+ text: string | undefined | null;
4
4
  flow?: 'top' | 'left' | 'right' | 'down';
5
- appendToBody?: boolean;
6
- disabled?: boolean;
7
5
  }
8
- export declare const Tooltip: React.FC<IProps>;
6
+ export declare class Tooltip extends React.PureComponent<IProps> {
7
+ private id;
8
+ private instance;
9
+ constructor(props: IProps);
10
+ private setupTooltip;
11
+ componentDidMount(): void;
12
+ componentDidUpdate(): void;
13
+ render(): JSX.Element;
14
+ }
9
15
  export {};
@@ -14,17 +14,6 @@ var __extends = (this && this.__extends) || (function () {
14
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
15
  };
16
16
  })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
17
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29
18
  if (k2 === undefined) k2 = k;
30
19
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -48,69 +37,80 @@ var __importStar = (this && this.__importStar) || function (mod) {
48
37
  __setModuleDefault(result, mod);
49
38
  return result;
50
39
  };
51
- var __rest = (this && this.__rest) || function (s, e) {
52
- var t = {};
53
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
54
- t[p] = s[p];
55
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
56
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
57
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
58
- t[p[i]] = s[p[i]];
59
- }
60
- return t;
61
- };
62
40
  var __importDefault = (this && this.__importDefault) || function (mod) {
63
41
  return (mod && mod.__esModule) ? mod : { "default": mod };
64
42
  };
65
43
  Object.defineProperty(exports, "__esModule", { value: true });
66
44
  exports.Tooltip = void 0;
67
45
  var React = __importStar(require("react"));
68
- var react_id_generator_1 = __importDefault(require("react-id-generator"));
69
- var tooltip_1 = require("@superdesk/primereact/tooltip");
70
- var Tooltip = function (_a) {
71
- var appendToBody = _a.appendToBody, children = _a.children, disabled = _a.disabled, otherProps = __rest(_a, ["appendToBody", "children", "disabled"]);
72
- return disabled
73
- ? React.createElement(React.Fragment, null, children)
74
- : appendToBody
75
- ? React.createElement(TooltipAppended, __assign({}, otherProps), children)
76
- : React.createElement(TooltipBasic, __assign({}, otherProps), children);
77
- };
78
- exports.Tooltip = Tooltip;
79
- var TooltipBasic = /** @class */ (function (_super) {
80
- __extends(TooltipBasic, _super);
81
- function TooltipBasic() {
82
- var _this = _super !== null && _super.apply(this, arguments) || this;
83
- _this.htmlId = (0, react_id_generator_1.default)();
46
+ var tippy_js_1 = __importDefault(require("tippy.js"));
47
+ var helpers_1 = require("../helpers");
48
+ function flowToPlacement(flow) {
49
+ switch (flow) {
50
+ case undefined:
51
+ return undefined;
52
+ case 'top':
53
+ return 'top';
54
+ case 'right':
55
+ return 'right';
56
+ case 'down':
57
+ return 'bottom';
58
+ case 'left':
59
+ return 'left';
60
+ default:
61
+ return (0, helpers_1.assertNever)(flow);
62
+ }
63
+ }
64
+ var Tooltip = /** @class */ (function (_super) {
65
+ __extends(Tooltip, _super);
66
+ function Tooltip(props) {
67
+ var _this = _super.call(this, props) || this;
68
+ _this.id = 'tooltip-' + Math.random().toString().slice(2);
69
+ _this.instance = null;
84
70
  return _this;
85
71
  }
86
- TooltipBasic.prototype.componentDidMount = function () {
87
- var tooltip = document.getElementById('t' + this.htmlId);
88
- tooltip === null || tooltip === void 0 ? void 0 : tooltip.setAttribute('data-sd-tooltip', this.props.text);
89
- if (this.props.flow) {
90
- tooltip === null || tooltip === void 0 ? void 0 : tooltip.setAttribute('data-flow', this.props.flow);
72
+ Tooltip.prototype.setupTooltip = function () {
73
+ var _a;
74
+ var placement = flowToPlacement((_a = this.props.flow) !== null && _a !== void 0 ? _a : 'top');
75
+ var content = this.props.text;
76
+ if (this.instance == null) {
77
+ this.instance = (0, tippy_js_1.default)('#' + this.id, {
78
+ placement: placement,
79
+ })[0];
80
+ if (content != null) {
81
+ this.instance.setContent(content);
82
+ }
83
+ else {
84
+ this.instance.hide();
85
+ this.instance.disable();
86
+ }
91
87
  }
92
- };
93
- TooltipBasic.prototype.render = function () {
94
- if (React.isValidElement(this.props.children)) {
95
- var attrs = { id: 't' + this.htmlId };
96
- return (React.cloneElement(this.props.children, attrs));
88
+ var willBeEnabled = content != null;
89
+ var isEnabled = this.instance.state.isEnabled;
90
+ if (isEnabled && willBeEnabled) {
91
+ this.instance.setContent(content);
92
+ }
93
+ else if (isEnabled) {
94
+ // enabled now, but needs to be disabled
95
+ this.instance.hide();
96
+ this.instance.disable();
97
97
  }
98
- else {
99
- return (React.createElement(React.Fragment, null));
98
+ else if (willBeEnabled) {
99
+ // disabled now, but needs to be enabled
100
+ this.instance.setContent(content);
101
+ this.instance.enable();
102
+ this.instance.show();
100
103
  }
101
104
  };
102
- return TooltipBasic;
105
+ Tooltip.prototype.componentDidMount = function () {
106
+ this.setupTooltip();
107
+ };
108
+ Tooltip.prototype.componentDidUpdate = function () {
109
+ this.setupTooltip();
110
+ };
111
+ Tooltip.prototype.render = function () {
112
+ return (React.createElement("div", { id: this.id, style: { display: 'inline-flex' } }, this.props.children));
113
+ };
114
+ return Tooltip;
103
115
  }(React.PureComponent));
104
- var TooltipAppended = function (_a) {
105
- var children = _a.children, flow = _a.flow, text = _a.text;
106
- var triggerId = "uif-tooltip-".concat(Math.random().toString().slice(2));
107
- var position = flow === "down" ? "bottom" : flow;
108
- return (React.createElement(React.Fragment, null,
109
- React.createElement(tooltip_1.Tooltip, { target: "#" + triggerId, content: text, position: position !== null && position !== void 0 ? position : 'top' }),
110
- React.isValidElement(children)
111
- ? (function () {
112
- var attrs = { id: triggerId };
113
- return React.cloneElement(children, attrs);
114
- })()
115
- : React.createElement(React.Fragment, null)));
116
- };
116
+ exports.Tooltip = Tooltip;