superdesk-ui-framework 4.0.27 → 4.0.29
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.
- package/app-typescript/components/Alert.tsx +11 -1
- package/app-typescript/components/Button.tsx +47 -17
- package/app-typescript/components/FormLabel.tsx +7 -1
- package/app-typescript/components/Label.tsx +2 -13
- package/app-typescript/components/RadioButtonGroup.tsx +6 -5
- package/app-typescript/components/SelectPreview.tsx +1 -1
- package/app-typescript/components/ShowPopup.tsx +28 -19
- package/app-typescript/components/Tooltip.tsx +22 -6
- package/app-typescript/components/TreeSelect/TreeSelect.tsx +4 -21
- package/app-typescript/components/TreeSelect/TreeSelectItem.tsx +1 -1
- package/app-typescript/components/TreeSelect/TreeSelectPill.tsx +1 -1
- package/app-typescript/helpers.tsx +13 -0
- package/app-typescript/index.ts +1 -0
- package/dist/components/Buttons.tsx +6 -6
- package/dist/examples.bundle.js +37093 -37033
- package/dist/playgrounds/react-playgrounds/TestGround.tsx +1 -1
- package/dist/superdesk-ui.bundle.js +36975 -36916
- package/dist/vendor.bundle.js +7 -7
- package/examples/pages/components/Buttons.tsx +6 -6
- package/examples/pages/playgrounds/react-playgrounds/TestGround.tsx +1 -1
- package/package.json +1 -1
- package/react/components/Alert.d.ts +1 -0
- package/react/components/Alert.js +5 -1
- package/react/components/Button.d.ts +1 -0
- package/react/components/Button.js +35 -4
- package/react/components/FormLabel.d.ts +1 -0
- package/react/components/FormLabel.js +1 -1
- package/react/components/Label.d.ts +0 -1
- package/react/components/Label.js +3 -15
- package/react/components/RadioButtonGroup.d.ts +3 -2
- package/react/components/RadioButtonGroup.js +3 -3
- package/react/components/SelectPreview.js +3 -3
- package/react/components/ShowPopup.d.ts +1 -1
- package/react/components/ShowPopup.js +7 -7
- package/react/components/Tooltip.d.ts +9 -1
- package/react/components/Tooltip.js +40 -10
- package/react/components/TreeSelect/TreeSelect.js +5 -14
- package/react/components/TreeSelect/TreeSelectItem.js +2 -2
- package/react/components/TreeSelect/TreeSelectPill.js +3 -3
- package/react/helpers.d.ts +1 -0
- package/react/helpers.js +14 -1
- package/react/index.d.ts +1 -0
- package/react/index.js +3 -1
package/dist/vendor.bundle.js
CHANGED
@@ -17296,11 +17296,11 @@ module.exports = __WEBPACK_EXTERNAL_MODULE_0__;
|
|
17296
17296
|
}
|
17297
17297
|
}.call(this));
|
17298
17298
|
|
17299
|
-
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(
|
17299
|
+
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(42), __webpack_require__(59)(module)))
|
17300
17300
|
|
17301
17301
|
/***/ }),
|
17302
17302
|
|
17303
|
-
/***/
|
17303
|
+
/***/ 42:
|
17304
17304
|
/***/ (function(module, exports) {
|
17305
17305
|
|
17306
17306
|
var g;
|
@@ -17328,7 +17328,7 @@ module.exports = g;
|
|
17328
17328
|
|
17329
17329
|
/***/ }),
|
17330
17330
|
|
17331
|
-
/***/
|
17331
|
+
/***/ 59:
|
17332
17332
|
/***/ (function(module, exports) {
|
17333
17333
|
|
17334
17334
|
module.exports = function(module) {
|
@@ -17357,7 +17357,7 @@ module.exports = function(module) {
|
|
17357
17357
|
|
17358
17358
|
/***/ }),
|
17359
17359
|
|
17360
|
-
/***/
|
17360
|
+
/***/ 75:
|
17361
17361
|
/***/ (function(module, exports, __webpack_require__) {
|
17362
17362
|
|
17363
17363
|
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
|
@@ -28254,7 +28254,7 @@ return jQuery;
|
|
28254
28254
|
|
28255
28255
|
__webpack_require__(18);
|
28256
28256
|
|
28257
|
-
__webpack_require__(
|
28257
|
+
__webpack_require__(75);
|
28258
28258
|
|
28259
28259
|
__webpack_require__(804);
|
28260
28260
|
|
@@ -28292,7 +28292,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
28292
28292
|
if ( true ) {
|
28293
28293
|
|
28294
28294
|
// AMD. Register as an anonymous module.
|
28295
|
-
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(
|
28295
|
+
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(75), __webpack_require__(805) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
|
28296
28296
|
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
|
28297
28297
|
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
|
28298
28298
|
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
@@ -29039,7 +29039,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
29039
29039
|
if ( true ) {
|
29040
29040
|
|
29041
29041
|
// AMD. Register as an anonymous module.
|
29042
|
-
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(
|
29042
|
+
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(75) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
|
29043
29043
|
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
|
29044
29044
|
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
|
29045
29045
|
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
@@ -17,7 +17,7 @@ export default class ButtonsDoc extends React.Component {
|
|
17
17
|
<Markup.ReactMarkup>
|
18
18
|
<Markup.ReactMarkupPreview>
|
19
19
|
<div className="docs-page__content-row">
|
20
|
-
<Button text="default" onClick={()=> false} />
|
20
|
+
<Button text="default" onClick={()=> false} tooltip="test tooltip" />
|
21
21
|
<Button text="primary" type="primary" onClick={()=> false} />
|
22
22
|
</div>
|
23
23
|
<p className="docs-page__paragraph">// Other colour options</p>
|
@@ -101,8 +101,8 @@ export default class ButtonsDoc extends React.Component {
|
|
101
101
|
|
102
102
|
<h3 className="docs-page__h3">Sizing</h3>
|
103
103
|
<p className="docs-page__paragraph">
|
104
|
-
For the default button, no size has to be specified.
|
105
|
-
To change the default size set the <code>size</code> value either to <code>small</code> or <code>large</code>.
|
104
|
+
For the default button, no size has to be specified.
|
105
|
+
To change the default size set the <code>size</code> value either to <code>small</code> or <code>large</code>.
|
106
106
|
For the button to take the full width of the container add <code>expand={'{true}'}</code>.
|
107
107
|
</p>
|
108
108
|
<Markup.ReactMarkup>
|
@@ -120,7 +120,7 @@ export default class ButtonsDoc extends React.Component {
|
|
120
120
|
</div>
|
121
121
|
<div className="docs-page__content-row">
|
122
122
|
<Button text="small expanded button" expand={true} size="small" onClick={()=> false} />
|
123
|
-
</div>
|
123
|
+
</div>
|
124
124
|
</Markup.ReactMarkupPreview>
|
125
125
|
<Markup.ReactMarkupCode>{`
|
126
126
|
<Button text="button large" size="large" onClick={()=> false} />
|
@@ -201,7 +201,7 @@ export default class ButtonsDoc extends React.Component {
|
|
201
201
|
<Button text="success" type="success" icon="ok" onClick={()=> false} />
|
202
202
|
<Button text="warning" type="warning" icon="exclamation-sign" onClick={()=> false} />
|
203
203
|
<Button text="alert" type="alert" icon="warning-sign" onClick={()=> false} />
|
204
|
-
|
204
|
+
|
205
205
|
<Button text="default" icon="info-sign" style="hollow" onClick={()=> false} />
|
206
206
|
<Button text="primary" type="primary" icon="plus-sign" style="hollow" onClick={()=> false} />
|
207
207
|
<Button text="success" type="success" icon="ok" style="hollow" onClick={()=> false} />
|
@@ -217,7 +217,7 @@ export default class ButtonsDoc extends React.Component {
|
|
217
217
|
</Markup.ReactMarkup>
|
218
218
|
|
219
219
|
<h3 className="docs-page__h3">Buttons with icon font only</h3>
|
220
|
-
<p className="docs-page__paragraph">Buttons can also contain only an icon, without any visible text. To achieve this specify the <code>icon</code> value and set <code>iconOnly={true}</code>.
|
220
|
+
<p className="docs-page__paragraph">Buttons can also contain only an icon, without any visible text. To achieve this specify the <code>icon</code> value and set <code>iconOnly={true}</code>.
|
221
221
|
The specified text value will be used for the <code>aria-label</code>.</p>
|
222
222
|
<Markup.ReactMarkup>
|
223
223
|
<Markup.ReactMarkupPreview>
|
@@ -2031,7 +2031,7 @@ export class TestGround extends React.Component<IProps, IState> {
|
|
2031
2031
|
|
2032
2032
|
<div className="sd-check__group-new sd-check-button__group--left">
|
2033
2033
|
<RadioButtonGroup
|
2034
|
-
value={this.state.value3}
|
2034
|
+
value={this.state.value3 ?? ''}
|
2035
2035
|
options={[
|
2036
2036
|
{label: "RadioButton with an icon", value: "somevalue4", icon: "th-list"},
|
2037
2037
|
{label: "RadioButton with no visible text, only an icon", value: "somevalue5", icon: "th", labelHidden: true},
|
package/package.json
CHANGED
@@ -77,7 +77,11 @@ var Alert = /** @class */ (function (_super) {
|
|
77
77
|
_b["sd-alert__info-btn--".concat(this.props.type)] = this.props.type,
|
78
78
|
_b['sd-alert__info-btn--hidden'] = this.state.open,
|
79
79
|
_b));
|
80
|
-
|
80
|
+
var styles = {};
|
81
|
+
if (this.props.fullWidth) {
|
82
|
+
styles.width = '100%';
|
83
|
+
}
|
84
|
+
return (React.createElement("div", { className: 'sd-alert__container', style: styles },
|
81
85
|
React.createElement("div", { className: classesAlert },
|
82
86
|
this.props.icon ?
|
83
87
|
React.createElement("span", { className: "sd-alert__icon" },
|
@@ -14,6 +14,17 @@ 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
|
+
};
|
17
28
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
18
29
|
if (k2 === undefined) k2 = k;
|
19
30
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
@@ -46,6 +57,7 @@ var React = __importStar(require("react"));
|
|
46
57
|
var classnames_1 = __importDefault(require("classnames"));
|
47
58
|
var Icon_1 = require("./Icon");
|
48
59
|
var Spinner_1 = require("./Spinner");
|
60
|
+
var Tooltip_1 = require("./Tooltip");
|
49
61
|
var Button = /** @class */ (function (_super) {
|
50
62
|
__extends(Button, _super);
|
51
63
|
function Button() {
|
@@ -67,11 +79,30 @@ var Button = /** @class */ (function (_super) {
|
|
67
79
|
_a['sd-flex-justify-start'] = this.props.textAlign === 'start',
|
68
80
|
_a['sd-flex-justify-end'] = this.props.textAlign === 'end',
|
69
81
|
_a));
|
70
|
-
return (React.createElement(
|
71
|
-
|
72
|
-
|
73
|
-
|
82
|
+
return (React.createElement(TooltipWrapper, { tooltipText: this.props.tooltip }, function (_a) {
|
83
|
+
var attributes = _a.attributes;
|
84
|
+
return (React.createElement("button", __assign({}, attributes, { id: _this.props.id, className: classes, tabIndex: 0, disabled: _this.props.disabled || _this.props.isLoading, "data-loading": _this.props.isLoading, onClick: _this.props.disabled ? function () { return false; } : function (event) { return _this.props.onClick(event); }, "aria-label": _this.props.iconOnly ? _this.props.text : '', "data-test-id": _this.props['data-test-id'], style: _this.props.noMargin ? { margin: 0 } : undefined }),
|
85
|
+
_this.props.isLoading ? React.createElement(Spinner_1.Spinner, { size: "mini" }) : null,
|
86
|
+
_this.props.icon && !_this.props.isLoading ? React.createElement(Icon_1.Icon, { ariaHidden: true, name: _this.props.icon }) : null,
|
87
|
+
_this.props.iconOnly ? null : _this.props.text));
|
88
|
+
}));
|
74
89
|
};
|
75
90
|
return Button;
|
76
91
|
}(React.PureComponent));
|
77
92
|
exports.Button = Button;
|
93
|
+
var TooltipWrapper = /** @class */ (function (_super) {
|
94
|
+
__extends(TooltipWrapper, _super);
|
95
|
+
function TooltipWrapper() {
|
96
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
97
|
+
}
|
98
|
+
TooltipWrapper.prototype.render = function () {
|
99
|
+
var _a = this.props, tooltipText = _a.tooltipText, children = _a.children;
|
100
|
+
return (tooltipText !== null && tooltipText !== void 0 ? tooltipText : '').length > 0
|
101
|
+
? (React.createElement(Tooltip_1.WithTooltip, { text: tooltipText }, function (_a) {
|
102
|
+
var attributes = _a.attributes;
|
103
|
+
return children({ attributes: attributes });
|
104
|
+
}))
|
105
|
+
: (React.createElement(React.Fragment, null, children({ attributes: {} })));
|
106
|
+
};
|
107
|
+
return TooltipWrapper;
|
108
|
+
}(React.PureComponent));
|
@@ -53,7 +53,7 @@ var FormLabel = /** @class */ (function (_super) {
|
|
53
53
|
var classes = (0, classnames_1.default)('form-label form-label--block', {
|
54
54
|
'form-label--light': this.props.style === 'light',
|
55
55
|
});
|
56
|
-
return (React.createElement("label", { className: classes }, this.props.text));
|
56
|
+
return (React.createElement("label", { className: classes, style: this.props.noMinHeight === true ? { minHeight: 'auto' } : undefined }, this.props.text));
|
57
57
|
};
|
58
58
|
return FormLabel;
|
59
59
|
}(React.PureComponent));
|
@@ -41,9 +41,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
41
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
42
42
|
};
|
43
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
44
|
-
exports.
|
44
|
+
exports.Label = void 0;
|
45
45
|
var React = __importStar(require("react"));
|
46
46
|
var classnames_1 = __importDefault(require("classnames"));
|
47
|
+
var helpers_1 = require("../helpers");
|
47
48
|
var Label = /** @class */ (function (_super) {
|
48
49
|
__extends(Label, _super);
|
49
50
|
function Label() {
|
@@ -79,7 +80,7 @@ var Label = /** @class */ (function (_super) {
|
|
79
80
|
}
|
80
81
|
else {
|
81
82
|
return (React.createElement("span", { className: classes, style: this.props.hexColor
|
82
|
-
? { backgroundColor: this.props.hexColor, color: getTextColor(this.props.hexColor) }
|
83
|
+
? { backgroundColor: this.props.hexColor, color: (0, helpers_1.getTextColor)(this.props.hexColor) }
|
83
84
|
: undefined }, this.props.text));
|
84
85
|
}
|
85
86
|
}
|
@@ -87,16 +88,3 @@ var Label = /** @class */ (function (_super) {
|
|
87
88
|
return Label;
|
88
89
|
}(React.PureComponent));
|
89
90
|
exports.Label = Label;
|
90
|
-
function getTextColor(backgroundColor) {
|
91
|
-
if (backgroundColor) {
|
92
|
-
var r = parseInt(backgroundColor.substr(1, 2), 16);
|
93
|
-
var g = parseInt(backgroundColor.substr(3, 2), 16);
|
94
|
-
var b = parseInt(backgroundColor.substr(5, 2), 16);
|
95
|
-
var yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000;
|
96
|
-
return (yiq >= 128) ? 'black' : 'white';
|
97
|
-
}
|
98
|
-
else {
|
99
|
-
return;
|
100
|
-
}
|
101
|
-
}
|
102
|
-
exports.getTextColor = getTextColor;
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
interface IProps {
|
3
|
-
value
|
3
|
+
value: string;
|
4
|
+
onChange(nextValue: string): void;
|
5
|
+
disabled?: boolean;
|
4
6
|
group?: {
|
5
7
|
orientation?: 'horizontal' | 'vertical';
|
6
8
|
grid?: boolean;
|
@@ -18,7 +20,6 @@ interface IProps {
|
|
18
20
|
}>;
|
19
21
|
required?: boolean;
|
20
22
|
tabindex?: number;
|
21
|
-
onChange(nextValue: string): void;
|
22
23
|
'data-test-id'?: string;
|
23
24
|
}
|
24
25
|
export declare class RadioButtonGroup extends React.Component<IProps> {
|
@@ -55,7 +55,7 @@ var RadioButtonGroup = /** @class */ (function (_super) {
|
|
55
55
|
return _this;
|
56
56
|
}
|
57
57
|
RadioButtonGroup.prototype.handleChange = function (item) {
|
58
|
-
if (
|
58
|
+
if (this.props.disabled !== true && item.disabled !== true) {
|
59
59
|
this.props.onChange(item.value);
|
60
60
|
}
|
61
61
|
};
|
@@ -79,7 +79,7 @@ var RadioButtonGroup = /** @class */ (function (_super) {
|
|
79
79
|
return (React.createElement(React.Fragment, null,
|
80
80
|
!((_j = this.props.group) === null || _j === void 0 ? void 0 : _j.groupLabel) ?
|
81
81
|
React.createElement("div", { role: "radiogroup", className: classes, "aria-labelledby": (_k = this.props.group) === null || _k === void 0 ? void 0 : _k.groupLabelledBy, "data-test-id": this.props['data-test-id'], "data-test-value": selectedOption == null ? undefined : selectedOption.label }, this.props.options.map(function (item, index) { return (React.createElement("span", { className: "sd-check-button sd-check-button--native", key: index, tabIndex: _this.props.tabindex === undefined ? undefined : -1 },
|
82
|
-
React.createElement("input", { type: "radio", className: "sd-check-button__input", id: _this.htmlId + index, tabIndex: _this.props.tabindex, name: _this.htmlId, onChange: function () { return _this.handleChange(item); }, disabled: item.disabled, required: _this.props.required, checked: item.value === _this.props.value }),
|
82
|
+
React.createElement("input", { type: "radio", className: "sd-check-button__input", id: _this.htmlId + index, tabIndex: _this.props.tabindex, name: _this.htmlId, onChange: function () { return _this.handleChange(item); }, disabled: _this.props.disabled || item.disabled, required: _this.props.required, checked: item.value === _this.props.value }),
|
83
83
|
React.createElement("label", { className: "sd-check-button__text-label", htmlFor: _this.htmlId + index, "aria-label": item.labelHidden ? item.label : undefined, "data-test-id": "item" },
|
84
84
|
item.icon ? React.createElement("i", { className: "icon-".concat(item.icon), "aria-hidden": "true" }) : null,
|
85
85
|
!item.labelHidden || !item.icon ?
|
@@ -89,7 +89,7 @@ var RadioButtonGroup = /** @class */ (function (_super) {
|
|
89
89
|
React.createElement("div", { className: 'sd-check-button__group-wrapper', "data-test-id": this.props['data-test-id'], "data-test-value": selectedOption == null ? undefined : selectedOption.label },
|
90
90
|
React.createElement(FormLabel_1.FormLabel, { forId: this.htmlId + 'group', text: this.props.group.groupLabel }),
|
91
91
|
React.createElement("div", { role: "radiogroup", id: this.htmlId + 'group', className: classes }, this.props.options.map(function (item, index) { return (React.createElement("span", { className: "sd-check-button sd-check-button--native", key: index, tabIndex: -1 },
|
92
|
-
React.createElement("input", { type: "radio", className: "sd-check-button__input", id: _this.htmlId + index, tabIndex: 0, name: _this.htmlId, onChange: function () { return _this.handleChange(item); }, disabled: item.disabled, required: _this.props.required, checked: item.value === _this.props.value }),
|
92
|
+
React.createElement("input", { type: "radio", className: "sd-check-button__input", id: _this.htmlId + index, tabIndex: 0, name: _this.htmlId, onChange: function () { return _this.handleChange(item); }, disabled: _this.props.disabled || item.disabled, required: _this.props.required, checked: item.value === _this.props.value }),
|
93
93
|
React.createElement("label", { className: "sd-check-button__text-label", htmlFor: _this.htmlId + index, "aria-label": item.labelHidden ? item.label : undefined },
|
94
94
|
item.icon ? React.createElement("i", { className: "icon-".concat(item.icon), "aria-hidden": "true" }) : null,
|
95
95
|
!item.labelHidden || !item.icon ?
|
@@ -44,7 +44,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
44
|
exports.SelectPreview = void 0;
|
45
45
|
var classnames_1 = __importDefault(require("classnames"));
|
46
46
|
var React = __importStar(require("react"));
|
47
|
-
var
|
47
|
+
var helpers_1 = require("../helpers");
|
48
48
|
var SelectPreview = /** @class */ (function (_super) {
|
49
49
|
__extends(SelectPreview, _super);
|
50
50
|
function SelectPreview() {
|
@@ -85,12 +85,12 @@ var SelectPreview = /** @class */ (function (_super) {
|
|
85
85
|
})() },
|
86
86
|
React.createElement("span", { className: "tags-input__helper-box", style: (function () {
|
87
87
|
if (backgroundColor != null) {
|
88
|
-
return { color: (0,
|
88
|
+
return { color: (0, helpers_1.getTextColor)(backgroundColor) };
|
89
89
|
}
|
90
90
|
else {
|
91
91
|
if (_this.props.kind.mode === 'multi-select'
|
92
92
|
&& _this.props.kind.getBackgroundColor != null) {
|
93
|
-
return { color: (0,
|
93
|
+
return { color: (0, helpers_1.getTextColor)(_this.props.kind.getBackgroundColor(item)) };
|
94
94
|
}
|
95
95
|
else {
|
96
96
|
return undefined;
|
@@ -64,7 +64,7 @@ var PopupPositioner = /** @class */ (function (_super) {
|
|
64
64
|
if (this.wrapperEl == null) {
|
65
65
|
return;
|
66
66
|
}
|
67
|
-
if (this.props.
|
67
|
+
if (this.props.getReferenceElement().contains(event.target) !== true
|
68
68
|
&& this.wrapperEl.contains(event.target) !== true) {
|
69
69
|
this.props.onClose();
|
70
70
|
}
|
@@ -90,7 +90,7 @@ var PopupPositioner = /** @class */ (function (_super) {
|
|
90
90
|
window.addEventListener('click', this.closeOnClick, { capture: true });
|
91
91
|
window.addEventListener('scroll', this.closeOnScroll, true);
|
92
92
|
if (this.props.closeOnHoverEnd && this.wrapperEl != null) {
|
93
|
-
this.props.
|
93
|
+
this.props.getReferenceElement().addEventListener('mouseleave', this.closeOnMouseLeave);
|
94
94
|
this.wrapperEl.addEventListener('mouseleave', this.closeOnMouseLeave);
|
95
95
|
}
|
96
96
|
var applyMaxSize = {
|
@@ -112,7 +112,7 @@ var PopupPositioner = /** @class */ (function (_super) {
|
|
112
112
|
*/
|
113
113
|
setTimeout(function () {
|
114
114
|
if (_this.wrapperEl != null) {
|
115
|
-
_this.popper = (0, core_1.createPopper)(_this.props.
|
115
|
+
_this.popper = (0, core_1.createPopper)(_this.props.getReferenceElement(), _this.wrapperEl, {
|
116
116
|
placement: _this.props.placement,
|
117
117
|
modifiers: [
|
118
118
|
popper_max_size_modifier_1.default,
|
@@ -128,21 +128,21 @@ var PopupPositioner = /** @class */ (function (_super) {
|
|
128
128
|
window.removeEventListener('click', this.closeOnClick);
|
129
129
|
window.removeEventListener('scroll', this.closeOnScroll, true);
|
130
130
|
if (this.props.closeOnHoverEnd && this.wrapperEl != null) {
|
131
|
-
this.props.
|
131
|
+
this.props.getReferenceElement().removeEventListener('mouseleave', this.closeOnMouseLeave);
|
132
132
|
this.wrapperEl.removeEventListener('mouseleave', this.closeOnMouseLeave);
|
133
133
|
}
|
134
134
|
(_b = (_a = this.popper) === null || _a === void 0 ? void 0 : _a.destroy) === null || _b === void 0 ? void 0 : _b.call(_a);
|
135
135
|
};
|
136
136
|
PopupPositioner.prototype.render = function () {
|
137
137
|
var _this = this;
|
138
|
-
return (React.createElement("div", { ref: function (el) {
|
138
|
+
return (React.createElement(React.Fragment, null, react_dom_1.default.createPortal((React.createElement("div", { ref: function (el) {
|
139
139
|
_this.wrapperEl = el;
|
140
140
|
}, style: {
|
141
141
|
position: 'absolute',
|
142
142
|
left: '-100vw',
|
143
143
|
display: 'flex',
|
144
144
|
zIndex: this.zIndex,
|
145
|
-
} }, this.props.children));
|
145
|
+
} }, this.props.children)), document.body)));
|
146
146
|
};
|
147
147
|
return PopupPositioner;
|
148
148
|
}(React.PureComponent));
|
@@ -158,7 +158,7 @@ function showPopup(referenceElement, placement, Component, closeOnHoverEnd, onCl
|
|
158
158
|
el.remove();
|
159
159
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
160
160
|
};
|
161
|
-
react_dom_1.default.render((React.createElement(PopupPositioner, {
|
161
|
+
react_dom_1.default.render((React.createElement(PopupPositioner, { getReferenceElement: function () { return referenceElement; }, placement: placement, onClose: closeFn, closeOnHoverEnd: closeOnHoverEnd || false },
|
162
162
|
React.createElement(Component, { closePopup: closeFn }))), el);
|
163
163
|
return { close: closeFn };
|
164
164
|
}
|
@@ -2,14 +2,22 @@ import * as React from 'react';
|
|
2
2
|
interface IProps {
|
3
3
|
text: string | undefined | null;
|
4
4
|
flow?: 'top' | 'left' | 'right' | 'down';
|
5
|
+
children(options: {
|
6
|
+
attributes: {
|
7
|
+
[name: string]: string;
|
8
|
+
};
|
9
|
+
}): React.ReactNode;
|
5
10
|
}
|
6
|
-
export declare class
|
11
|
+
export declare class WithTooltip extends React.PureComponent<IProps> {
|
7
12
|
private id;
|
8
13
|
private instance;
|
9
14
|
constructor(props: IProps);
|
10
15
|
private setupTooltip;
|
11
16
|
componentDidMount(): void;
|
12
17
|
componentDidUpdate(): void;
|
18
|
+
render(): React.ReactNode;
|
19
|
+
}
|
20
|
+
export declare class Tooltip extends React.PureComponent<Omit<IProps, 'children'>> {
|
13
21
|
render(): JSX.Element;
|
14
22
|
}
|
15
23
|
export {};
|
@@ -14,6 +14,17 @@ 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
|
+
};
|
17
28
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
18
29
|
if (k2 === undefined) k2 = k;
|
19
30
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
@@ -41,8 +52,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
52
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
42
53
|
};
|
43
54
|
Object.defineProperty(exports, "__esModule", { value: true });
|
44
|
-
exports.Tooltip = void 0;
|
55
|
+
exports.Tooltip = exports.WithTooltip = void 0;
|
45
56
|
var React = __importStar(require("react"));
|
57
|
+
var react_id_generator_1 = __importDefault(require("react-id-generator"));
|
46
58
|
var tippy_js_1 = __importDefault(require("tippy.js"));
|
47
59
|
var helpers_1 = require("../helpers");
|
48
60
|
function flowToPlacement(flow) {
|
@@ -61,20 +73,22 @@ function flowToPlacement(flow) {
|
|
61
73
|
return (0, helpers_1.assertNever)(flow);
|
62
74
|
}
|
63
75
|
}
|
64
|
-
var
|
65
|
-
|
66
|
-
|
76
|
+
var tooltipAttributeName = 'data-with-tooltip';
|
77
|
+
var getTooltipSelector = function (value) { return "[".concat(tooltipAttributeName, "=").concat(value, "]"); };
|
78
|
+
var WithTooltip = /** @class */ (function (_super) {
|
79
|
+
__extends(WithTooltip, _super);
|
80
|
+
function WithTooltip(props) {
|
67
81
|
var _this = _super.call(this, props) || this;
|
68
|
-
_this.id =
|
82
|
+
_this.id = (0, react_id_generator_1.default)();
|
69
83
|
_this.instance = null;
|
70
84
|
return _this;
|
71
85
|
}
|
72
|
-
|
86
|
+
WithTooltip.prototype.setupTooltip = function () {
|
73
87
|
var _a;
|
74
88
|
var placement = flowToPlacement((_a = this.props.flow) !== null && _a !== void 0 ? _a : 'top');
|
75
89
|
var content = this.props.text;
|
76
90
|
if (this.instance == null) {
|
77
|
-
this.instance = (0, tippy_js_1.default)(
|
91
|
+
this.instance = (0, tippy_js_1.default)(getTooltipSelector(this.id), {
|
78
92
|
placement: placement,
|
79
93
|
})[0];
|
80
94
|
if (this.instance == null) {
|
@@ -106,14 +120,30 @@ var Tooltip = /** @class */ (function (_super) {
|
|
106
120
|
this.instance.show();
|
107
121
|
}
|
108
122
|
};
|
109
|
-
|
123
|
+
WithTooltip.prototype.componentDidMount = function () {
|
110
124
|
this.setupTooltip();
|
111
125
|
};
|
112
|
-
|
126
|
+
WithTooltip.prototype.componentDidUpdate = function () {
|
113
127
|
this.setupTooltip();
|
114
128
|
};
|
129
|
+
WithTooltip.prototype.render = function () {
|
130
|
+
var _a;
|
131
|
+
return this.props.children({ attributes: (_a = {}, _a[tooltipAttributeName] = this.id, _a) });
|
132
|
+
};
|
133
|
+
return WithTooltip;
|
134
|
+
}(React.PureComponent));
|
135
|
+
exports.WithTooltip = WithTooltip;
|
136
|
+
var Tooltip = /** @class */ (function (_super) {
|
137
|
+
__extends(Tooltip, _super);
|
138
|
+
function Tooltip() {
|
139
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
140
|
+
}
|
115
141
|
Tooltip.prototype.render = function () {
|
116
|
-
|
142
|
+
var _this = this;
|
143
|
+
return (React.createElement(WithTooltip, { text: this.props.text, flow: this.props.flow }, function (_a) {
|
144
|
+
var attributes = _a.attributes;
|
145
|
+
return (React.createElement("div", __assign({}, attributes, { style: { display: 'inline-flex' } }), _this.props.children));
|
146
|
+
}));
|
117
147
|
};
|
118
148
|
return Tooltip;
|
119
149
|
}(React.PureComponent));
|
@@ -70,7 +70,7 @@ var debounce_1 = __importDefault(require("lodash/debounce"));
|
|
70
70
|
var Form_1 = require("../Form");
|
71
71
|
var core_1 = require("@popperjs/core");
|
72
72
|
var lodash_1 = require("lodash");
|
73
|
-
var
|
73
|
+
var helpers_1 = require("../../helpers");
|
74
74
|
var SelectPreview_1 = require("../SelectPreview");
|
75
75
|
var TreeSelectPill_1 = require("./TreeSelectPill");
|
76
76
|
var TreeSelectItem_1 = require("./TreeSelectItem");
|
@@ -78,12 +78,7 @@ var KeyboardNavigation_1 = require("./KeyboardNavigation");
|
|
78
78
|
var WithPortal_1 = require("../WithPortal");
|
79
79
|
var react_beautiful_dnd_1 = require("react-beautiful-dnd");
|
80
80
|
var zIndex_1 = require("../../zIndex");
|
81
|
-
var
|
82
|
-
var result = Array.from(list);
|
83
|
-
var removed = result.splice(startIndex, 1)[0];
|
84
|
-
result.splice(endIndex, 0, removed);
|
85
|
-
return result;
|
86
|
-
};
|
81
|
+
var common_1 = require("@superdesk/common");
|
87
82
|
var TreeSelect = /** @class */ (function (_super) {
|
88
83
|
__extends(TreeSelect, _super);
|
89
84
|
function TreeSelect(props) {
|
@@ -250,12 +245,9 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
250
245
|
}
|
251
246
|
};
|
252
247
|
TreeSelect.prototype.removeClick = function (i) {
|
253
|
-
var newTags = this.state.value;
|
254
|
-
newTags === null || newTags === void 0 ? void 0 : newTags.splice(i, 1);
|
255
248
|
this.setState({
|
256
|
-
value:
|
249
|
+
value: this.state.value.filter(function (_item, index) { return index !== i; }),
|
257
250
|
});
|
258
|
-
this.props.onChange(this.state.value);
|
259
251
|
};
|
260
252
|
TreeSelect.prototype.handleMultiLevel = function (item) {
|
261
253
|
if (item.children) {
|
@@ -531,9 +523,8 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
531
523
|
if (!result.destination) {
|
532
524
|
return;
|
533
525
|
}
|
534
|
-
var value = reorder(this.state.value, result.source.index, result.destination.index);
|
535
526
|
this.setState({
|
536
|
-
value: value,
|
527
|
+
value: (0, common_1.arrayMove)(this.state.value, result.source.index, result.destination.index),
|
537
528
|
});
|
538
529
|
};
|
539
530
|
TreeSelect.prototype.render = function () {
|
@@ -622,7 +613,7 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
622
613
|
&& React.createElement("div", { className: "item-border item-border-selected", style: borderColor
|
623
614
|
? { backgroundColor: borderColor }
|
624
615
|
: { backgroundColor: _this.props.getBorderColor(item) } }),
|
625
|
-
React.createElement("span", { className: "tags-input__helper-box", style: { color: backgroundColor && (0,
|
616
|
+
React.createElement("span", { className: "tags-input__helper-box", style: { color: backgroundColor && (0, helpers_1.getTextColor)(backgroundColor) } },
|
626
617
|
React.createElement("span", { className: backgroundColor && "tags-input__tag-item", style: { backgroundColor: backgroundColor, margin: 0 }, "data-test-id": "item" }, children),
|
627
618
|
(_this.props.readOnly !== true && _this.props.required !== true) && (React.createElement("span", { className: "tags-input__remove-button", "data-test-id": "clear-value" },
|
628
619
|
React.createElement(Icon_1.Icon, { name: 'remove-sign' }))))));
|
@@ -41,7 +41,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
41
|
exports.TreeSelectItem = exports.getPrefixedItemId = void 0;
|
42
42
|
var React = __importStar(require("react"));
|
43
43
|
var Icon_1 = require("../Icon");
|
44
|
-
var
|
44
|
+
var helpers_1 = require("../../helpers");
|
45
45
|
function getPrefixedItemId(id) {
|
46
46
|
return id + '-focus';
|
47
47
|
}
|
@@ -82,7 +82,7 @@ var TreeSelectItem = /** @class */ (function (_super) {
|
|
82
82
|
+ (this.props.selectedItem ? ' suggestion-item--selected' : ''), style: (this.props.getBackgroundColor && this.props.option.value)
|
83
83
|
? {
|
84
84
|
backgroundColor: this.props.getBackgroundColor(this.props.option.value),
|
85
|
-
color: (0,
|
85
|
+
color: (0, helpers_1.getTextColor)(this.props.getBackgroundColor(this.props.option.value)),
|
86
86
|
}
|
87
87
|
: undefined, "aria-label": ariaLabel }, this.props.optionTemplate
|
88
88
|
? this.props.optionTemplate(this.props.option.value)
|